From 5e30de407475f4d999ce850f7ce3da324a493605 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 6 Jun 2006 18:49:34 +0000 Subject: [PATCH] 2006-06-06 Alex Roitman * src/GrampsDb/_DbUtils.py (set_birth_death_index): Only set birth and death references for events with primary role. svn: r6866 --- gramps2/ChangeLog | 4 ++++ gramps2/src/GrampsDb/_DbUtils.py | 28 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 7bd497838..a0640df6d 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2006-06-06 Alex Roitman + * src/GrampsDb/_DbUtils.py (set_birth_death_index): Only set birth + and death references for events with primary role. + 2006-06-05 Don Allingham * src/GrampsDb/_ReadGedcom.py: more improvements diff --git a/gramps2/src/GrampsDb/_DbUtils.py b/gramps2/src/GrampsDb/_DbUtils.py index 87179ba5d..2f17854ab 100644 --- a/gramps2/src/GrampsDb/_DbUtils.py +++ b/gramps2/src/GrampsDb/_DbUtils.py @@ -274,16 +274,20 @@ def update_secondary_inmem(sec_table,handle,data): sec_table[str(data[1])] = str(handle) def set_birth_death_index(db, person): - birth = -1 - death = -1 - index = 0 - for ref in person.get_event_ref_list(): + birth_ref_index = -1 + death_ref_index = -1 + event_ref_list = person.get_event_ref_list() + for index in range(len(event_ref_list)): + ref = event_ref_list[index] event = db.get_event_from_handle(ref.ref) - if int(event.get_type()) == RelLib.EventType.BIRTH and birth == -1: - birth = index - elif int(event.get_type()) == RelLib.EventType.DEATH and death == -1: - death = index - index += 1 - person.birth_ref_index = birth - person.death_ref_index = death - + if (int(event.get_type()) == RelLib.EventType.BIRTH) \ + and (int(ref.get_role()) == RelLib.EventRoleType.PRIMARY) \ + and (birth_ref_index == -1): + birth_ref_index = index + elif (int(event.get_type()) == RelLib.EventType.DEATH) \ + and (int(ref.get_role()) == RelLib.EventRoleType.PRIMARY) \ + and (death_ref_index == -1): + death_ref_index = index + + person.birth_ref_index = birth_ref_index + person.death_ref_index = death_ref_index