PlaceName constructor shortcut; Place.set_name type check;
bug fixes for testcasegenerator 1. Added PlaceName(value=..., lang=...) shortcut; will add to others 2. Added an instance check on Place.set_name() to make sure it is a PlaceName 3. Fixed Testcasegenerator to make proper fake places, and a bug in handling windows
This commit is contained in:
parent
a943e63b84
commit
51402bd486
@ -314,6 +314,8 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
|||||||
:param name: name to assign to the Place
|
:param name: name to assign to the Place
|
||||||
:type name: PlaceName
|
:type name: PlaceName
|
||||||
"""
|
"""
|
||||||
|
if not isinstance(name, PlaceName):
|
||||||
|
raise ValueError("Place.set_name(name) requires a PlaceName()")
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
def get_name(self):
|
def get_name(self):
|
||||||
|
@ -45,7 +45,7 @@ class PlaceName(SecondaryObject, DateBase):
|
|||||||
This class is for keeping information about place names.
|
This class is for keeping information about place names.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Create a new PlaceName instance, copying from the source if present.
|
Create a new PlaceName instance, copying from the source if present.
|
||||||
"""
|
"""
|
||||||
@ -56,6 +56,11 @@ class PlaceName(SecondaryObject, DateBase):
|
|||||||
else:
|
else:
|
||||||
self.value = ''
|
self.value = ''
|
||||||
self.lang = ''
|
self.lang = ''
|
||||||
|
for key in kwargs:
|
||||||
|
if key in ["value", "lang"]:
|
||||||
|
setattr(self, key, kwargs[key])
|
||||||
|
else:
|
||||||
|
raise AttributeError("PlaceName does not have property '%s'" % key)
|
||||||
|
|
||||||
def serialize(self):
|
def serialize(self):
|
||||||
"""
|
"""
|
||||||
|
@ -50,7 +50,7 @@ from gramps.gen.lib import (Address, Attribute, AttributeType, ChildRef,
|
|||||||
ChildRefType, Citation, Date, Event, EventRef, EventRoleType,
|
ChildRefType, Citation, Date, Event, EventRef, EventRoleType,
|
||||||
EventType, Family, FamilyRelType, GrampsType, LdsOrd, Location,
|
EventType, Family, FamilyRelType, GrampsType, LdsOrd, Location,
|
||||||
MediaObject, MediaRef, Name, NameOriginType, NameType, Note,
|
MediaObject, MediaRef, Name, NameOriginType, NameType, Note,
|
||||||
NoteType, Person, PersonRef, Place, PlaceType, PlaceRef,
|
NoteType, Person, PersonRef, Place, PlaceType, PlaceRef, PlaceName,
|
||||||
RepoRef, Repository, RepositoryType, Source, SourceMediaType,
|
RepoRef, Repository, RepositoryType, Source, SourceMediaType,
|
||||||
SrcAttribute, SrcAttributeType, Surname, Tag, Url, UrlType)
|
SrcAttribute, SrcAttributeType, Surname, Tag, Url, UrlType)
|
||||||
from gramps.gen.lib.addressbase import AddressBase
|
from gramps.gen.lib.addressbase import AddressBase
|
||||||
@ -194,6 +194,7 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
def init_gui(self,uistate):
|
def init_gui(self,uistate):
|
||||||
title = "%s - Gramps" % _("Generate testcases")
|
title = "%s - Gramps" % _("Generate testcases")
|
||||||
self.top = Gtk.Dialog(title, parent=uistate.window)
|
self.top = Gtk.Dialog(title, parent=uistate.window)
|
||||||
|
self.window = uistate.window
|
||||||
self.top.set_default_size(400,150)
|
self.top.set_default_size(400,150)
|
||||||
self.top.vbox.set_spacing(5)
|
self.top.vbox.set_spacing(5)
|
||||||
label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>' % _("Generate testcases"))
|
label = Gtk.Label(label='<span size="larger" weight="bold">%s</span>' % _("Generate testcases"))
|
||||||
@ -1670,7 +1671,7 @@ class TestcaseGenerator(tool.BatchTool):
|
|||||||
|
|
||||||
if isinstance(o, Place):
|
if isinstance(o, Place):
|
||||||
o.set_title(self.rand_text(self.LONG))
|
o.set_title(self.rand_text(self.LONG))
|
||||||
o.set_name(self.rand_text(self.SHORT))
|
o.set_name(PlaceName(value=self.rand_text(self.SHORT)))
|
||||||
o.set_code(self.rand_text(self.SHORT))
|
o.set_code(self.rand_text(self.SHORT))
|
||||||
if randint(0, 1) == 1:
|
if randint(0, 1) == 1:
|
||||||
if randint(0, 4) == 1:
|
if randint(0, 4) == 1:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user