Added get_gedcom_name formatter to Name to allow sharing
svn: r13251
This commit is contained in:
parent
4f343de138
commit
0c856f59f5
@ -397,3 +397,43 @@ class Name(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase):
|
|||||||
self.suffix)
|
self.suffix)
|
||||||
else:
|
else:
|
||||||
return "%s %s, %s" % (first, self.surname, self.suffix)
|
return "%s %s, %s" % (first, self.surname, self.suffix)
|
||||||
|
|
||||||
|
def get_gedcom_parts(self):
|
||||||
|
"""
|
||||||
|
Returns a GEDCOM-formatted name dictionary.
|
||||||
|
"""
|
||||||
|
retval = {}
|
||||||
|
retval['given'] = self.first_name.strip()
|
||||||
|
retval['patronymic'] = self.patronymic.strip()
|
||||||
|
if retval['patronymic']:
|
||||||
|
retval['given'] = "%s %s" % (retval['given'],
|
||||||
|
retval['patronymic'])
|
||||||
|
retval['surname'] = self.surname.replace('/', '?')
|
||||||
|
retval['prefix'] = self.prefix.replace('/', '?')
|
||||||
|
retval['suffix'] = self.suffix
|
||||||
|
retval['title'] = self.title
|
||||||
|
return retval
|
||||||
|
|
||||||
|
def get_gedcom_name(self):
|
||||||
|
"""
|
||||||
|
Returns a GEDCOM-formatted name.
|
||||||
|
"""
|
||||||
|
firstname = self.first_name.strip()
|
||||||
|
patron = self.patronymic.strip()
|
||||||
|
if patron:
|
||||||
|
firstname = "%s %s" % (firstname, patron)
|
||||||
|
surname = self.surname.replace('/', '?')
|
||||||
|
surprefix = self.prefix.replace('/', '?')
|
||||||
|
suffix = self.suffix
|
||||||
|
title = self.title
|
||||||
|
if suffix == "":
|
||||||
|
if surprefix == "":
|
||||||
|
return '%s /%s/' % (firstname, surname)
|
||||||
|
else:
|
||||||
|
return '%s /%s %s/' % (firstname, surprefix, surname)
|
||||||
|
elif surprefix == "":
|
||||||
|
return '%s /%s/ %s' % (firstname, surname, suffix)
|
||||||
|
else:
|
||||||
|
return '%s /%s %s/ %s' % (firstname, surprefix, surname, suffix)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1239,27 +1239,18 @@ class GedcomWriter(BasicUtils.UpdateCallback):
|
|||||||
+1 <<SOURCE_CITATION>> {0:M}
|
+1 <<SOURCE_CITATION>> {0:M}
|
||||||
+1 <<NOTE_STRUCTURE>> {0:M}
|
+1 <<NOTE_STRUCTURE>> {0:M}
|
||||||
"""
|
"""
|
||||||
|
gedcom_name = name.get_gedcom_name()
|
||||||
|
|
||||||
firstname = name.get_first_name().strip()
|
firstname = name.get_first_name().strip()
|
||||||
patron = name.get_patronymic().strip()
|
patron = name.get_patronymic().strip()
|
||||||
if patron:
|
if patron:
|
||||||
firstname = "%s %s" % (firstname, patron)
|
firstname = "%s %s" % (firstname, patron)
|
||||||
|
|
||||||
surname = name.get_surname().replace('/', '?')
|
surname = name.get_surname().replace('/', '?')
|
||||||
surprefix = name.get_surname_prefix().replace('/', '?')
|
surprefix = name.get_surname_prefix().replace('/', '?')
|
||||||
suffix = name.get_suffix()
|
suffix = name.get_suffix()
|
||||||
title = name.get_title()
|
title = name.get_title()
|
||||||
if suffix == "":
|
|
||||||
if surprefix == "":
|
self.__writeln(1, 'NAME', gedcom_name)
|
||||||
self.__writeln(1, 'NAME', '%s /%s/' % (firstname, surname))
|
|
||||||
else:
|
|
||||||
self.__writeln(1, 'NAME', '%s /%s %s/' %
|
|
||||||
(firstname, surprefix, surname))
|
|
||||||
elif surprefix == "":
|
|
||||||
self.__writeln(1, 'NAME', '%s /%s/ %s' %
|
|
||||||
(firstname, surname, suffix))
|
|
||||||
else:
|
|
||||||
self.__writeln(1, 'NAME', '%s /%s %s/ %s' %
|
|
||||||
(firstname, surprefix, surname, suffix))
|
|
||||||
|
|
||||||
if firstname:
|
if firstname:
|
||||||
self.__writeln(2, 'GIVN', firstname)
|
self.__writeln(2, 'GIVN', firstname)
|
||||||
|
Loading…
Reference in New Issue
Block a user