Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add substitution key for maiden name #1440

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions gramps/gen/lib/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
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
Expand Down Expand Up @@ -635,6 +636,18 @@ def get_nick_name(self):
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.
Expand Down
9 changes: 8 additions & 1 deletion gramps/plugins/lib/libsubstkeyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ def __init__(self, friend, database, consumer_in, locale, name_displayer):
def is_a(self):
""" check """
return self._in.this == "$" and self._in.next is not None and \
"nsijbBdDmMvVauetTpPG".find(self._in.next) != -1
"nhsijbBdDmMvVauetTpPG".find(self._in.next) != -1

def get_event_by_type(self, marriage, e_type):
""" get an event from a type """
Expand Down Expand Up @@ -946,6 +946,13 @@ def parse_format(self):
if next_char == "n":
#Person's name
return self.__parse_name(self.friend.person, attrib_parse)

elif next_char == "h":
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)
Expand Down