diff --git a/src/gen/lib/name.py b/src/gen/lib/name.py index 9fe521071..dedb43a8d 100644 --- a/src/gen/lib/name.py +++ b/src/gen/lib/name.py @@ -397,3 +397,43 @@ class Name(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase): self.suffix) else: 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) + + diff --git a/src/plugins/export/ExportGedcom.py b/src/plugins/export/ExportGedcom.py index cc6fa96d9..5579bfdf1 100644 --- a/src/plugins/export/ExportGedcom.py +++ b/src/plugins/export/ExportGedcom.py @@ -1239,27 +1239,18 @@ class GedcomWriter(BasicUtils.UpdateCallback): +1 <> {0:M} +1 <> {0:M} """ + gedcom_name = name.get_gedcom_name() + firstname = name.get_first_name().strip() patron = name.get_patronymic().strip() if patron: firstname = "%s %s" % (firstname, patron) - surname = name.get_surname().replace('/', '?') surprefix = name.get_surname_prefix().replace('/', '?') suffix = name.get_suffix() title = name.get_title() - if suffix == "": - if surprefix == "": - 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)) + + self.__writeln(1, 'NAME', gedcom_name) if firstname: self.__writeln(2, 'GIVN', firstname)