Add substitution for maiden name

This commit is contained in:
Jan Wolf 2023-05-27 20:47:40 +02:00
parent e5ec6bd7c9
commit d84c3cc1d1
2 changed files with 21 additions and 2 deletions

View File

@ -40,6 +40,7 @@ from .ldsordbase import LdsOrdBase
from .urlbase import UrlBase
from .tagbase import TagBase
from .name import Name
from .nametype import NameType
from .eventref import EventRef
from .personref import PersonRef
from .attrtype import AttributeType
@ -635,6 +636,18 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
return attr.get_value()
return ''
def get_maiden_name(self):
married_name = None
birth_name = None
for name in [self.get_primary_name()] + self.get_alternate_names():
if name.get_type() == NameType.BIRTH and name.get_surname():
birth_name = name.get_surname()
elif name.get_type() == NameType.MARRIED and name.get_surname():
married_name = name.get_surname()
if birth_name and married_name and birth_name != married_name:
return birth_name
return None
def set_gender(self, gender):
"""
Set the gender of the Person.

View File

@ -186,7 +186,7 @@ class NameFormat(GenericFormat):
common, # x
name.get_suffix, # s
name.get_surname, # l
name.get_family_nick_name # g
name.get_family_nick_name, # g
]
return self.generic_format(name, code, upper, function)
@ -823,7 +823,7 @@ class VariableParse:
def is_a(self):
""" check """
return self._in.this == "$" and self._in.next is not None and \
"nsijbBdDmMvVauetTpPG".find(self._in.next) != -1
"näsijbBdDmMvVauetTpPG".find(self._in.next) != -1
def get_event_by_type(self, marriage, e_type):
""" get an event from a type """
@ -946,6 +946,12 @@ class VariableParse:
if next_char == "n":
#Person's name
return self.__parse_name(self.friend.person, attrib_parse)
elif next_char == "ä":
if self.empty_item(self.friend.person):
return
# print(self.friend.person.get_maiden_name())
return self.friend.person.get_maiden_name()
elif next_char == "s":
#Souses name
return self.__parse_name(self.friend.spouse, attrib_parse)