7692: Add alternative place names to Gramps XML
This commit is contained in:
parent
9c879279a6
commit
5468dd31d0
@ -472,6 +472,35 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
if placeref.ref == old_handle:
|
||||
placeref.ref = new_handle
|
||||
|
||||
def get_alternative_names(self):
|
||||
"""
|
||||
Return a list of alternative names for the current Place.
|
||||
|
||||
:returns: Returns the alternative names for the Place
|
||||
:rtype: list of strings
|
||||
"""
|
||||
return self.alt_names
|
||||
|
||||
def set_alternative_names(self, name_list):
|
||||
"""
|
||||
Replace the current alternative names list with the new one.
|
||||
|
||||
:param name_list: The list of names to assign to the Place's internal
|
||||
list.
|
||||
:type name_list: list of strings
|
||||
"""
|
||||
self.alt_names = name_list
|
||||
|
||||
def add_alternative_name(self, name):
|
||||
"""
|
||||
Add a name to the alternative names list.
|
||||
|
||||
:param name: name to add
|
||||
:type name: string
|
||||
"""
|
||||
if name not in self.alt_names:
|
||||
self.alt_names.append(name)
|
||||
|
||||
def get_alternate_locations(self):
|
||||
"""
|
||||
Return a list of alternate :class:`~.location.Location` objects the
|
||||
|
@ -1200,6 +1200,8 @@ class GrampsXmlWriter(UpdateCallback):
|
||||
self.write_line_nofix("pname", name, index+1)
|
||||
self.write_line_nofix("type", ptype, index+1)
|
||||
self.write_line_nofix("code", code, index+1)
|
||||
for name in place.get_alternative_names():
|
||||
self.write_line("alt_name", name, index+1)
|
||||
|
||||
longitude = self.fix(place.get_longitude())
|
||||
lat = self.fix(place.get_latitude())
|
||||
|
@ -626,6 +626,7 @@ class GrampsParser(UpdateCallback):
|
||||
#other
|
||||
"address": (self.start_address, self.stop_address),
|
||||
"addresses": (None, None),
|
||||
"alt_name": (None, self.stop_alt_name),
|
||||
"childlist": (None, None),
|
||||
"attribute": (self.start_attribute, self.stop_attribute),
|
||||
"attr_type": (None, self.stop_attr_type),
|
||||
@ -2583,6 +2584,9 @@ class GrampsParser(UpdateCallback):
|
||||
def stop_code(self, tag):
|
||||
self.placeobj.code = tag
|
||||
|
||||
def stop_alt_name(self, tag):
|
||||
self.placeobj.add_alternative_name(tag)
|
||||
|
||||
def stop_placeobj(self, *tag):
|
||||
self.db.commit_place(self.placeobj, self.trans,
|
||||
self.placeobj.get_change_time())
|
||||
|
Loading…
Reference in New Issue
Block a user