From d84c3cc1d12c2ebc456588ee6d29a22fdd7b09dd Mon Sep 17 00:00:00 2001 From: Jan Wolf Date: Sat, 27 May 2023 20:47:40 +0200 Subject: [PATCH] Add substitution for maiden name --- gramps/gen/lib/person.py | 13 +++++++++++++ gramps/plugins/lib/libsubstkeyword.py | 10 ++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/gramps/gen/lib/person.py b/gramps/gen/lib/person.py index 00ec9462d..e894df170 100644 --- a/gramps/gen/lib/person.py +++ b/gramps/gen/lib/person.py @@ -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. diff --git a/gramps/plugins/lib/libsubstkeyword.py b/gramps/plugins/lib/libsubstkeyword.py index 3a9d5d34a..65a51995f 100644 --- a/gramps/plugins/lib/libsubstkeyword.py +++ b/gramps/plugins/lib/libsubstkeyword.py @@ -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)