Add name keys for indexing in reports

svn: r6809
This commit is contained in:
Brian Matherly
2006-05-29 02:52:14 +00:00
parent 4527627bd9
commit 1d225c91db
18 changed files with 159 additions and 72 deletions

View File

@@ -2196,3 +2196,37 @@ def common_name(person,use_nick=False):
return person.get_nick_name()
else:
return person.get_primary_name().get_first_name()
#-------------------------------------------------------------------------
#
# Indexing function
#
#-------------------------------------------------------------------------
def get_person_key(db,person):
"""
Returns a key that can be used to index a person in a report
@param db: the GRAMPS database instance
@param person: the the key is for
"""
name = person.get_primary_name().get_name()
birth = " "
death = " "
key = ""
birth_ref = person.get_birth_ref()
if birth_ref:
birthEvt = db.get_event_from_handle(birth_ref.ref)
birth = DateHandler.get_date(birthEvt)
death_ref = person.get_death_ref()
if death_ref:
deathEvt = db.get_event_from_handle(death_ref.ref)
death = DateHandler.get_date(deathEvt)
if birth == " " and death == " ":
key = name
else:
key = "%s (%s - %s)" % (name,birth,death)
return key