From f8f8f480f857b60ffe8b234f244231c7d8663af0 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Tue, 22 Jul 2003 10:52:55 +0000 Subject: [PATCH] 2003-07-22 Tim Waugh * src/RelLib.py: Made Person.probablyAlive() take partners into consideration if all else fails. svn: r1919 --- gramps2/ChangeLog | 2 ++ gramps2/src/RelLib.py | 54 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 45 insertions(+), 11 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index b755c72ee..4dc825970 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,6 @@ 2003-07-22 Tim Waugh + * src/RelLib.py: Made Person.probablyAlive() take partners into + consideration if all else fails. * src/plugins/WriteGedcom.py, src/plugins/gedcomexport.glade: New option for obscuring names of living people. diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 8f0a447f2..6d0b2cfa3 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -1394,6 +1394,8 @@ class Person(Persistent): # for descendants that were born more than a lifespan ago. min_generation = 13 + max_generation = 60 + max_age_difference = 60 def descendants_too_old (person, years): for family in person.getFamilyList (): for child in family.getChildList (): @@ -1417,26 +1419,56 @@ class Person(Persistent): return 0 # What about their parents? - family = self.getMainParents () - if family: - for parent in [family.getFather (), family.getMother ()]: - if not parent: + def parents_too_old (person, age_difference): + family = person.getMainParents () + if family: + for parent in [family.getFather (), family.getMother ()]: + if not parent: + continue + + if parent.birth.getDate () != "": + d = SingleDate (parent.birth.getDateObj (). + get_start_date ()) + d.setYear (d.getYear () + max_generation + + age_difference) + if not not_too_old (d): + return 1 + + if parent.death.getDate () != "": + d = SingleDate (parent.death.getDateObj (). + get_start_date ()) + d.setYear (d.getYear () + age_difference) + if not not_too_old (d): + return 1 + + if parents_too_old (self, 0): + return 0 + + # As a last resort, trying seeing if their spouse's age gives + # any clue. + for family in self.getFamilyList (): + for spouse in [family.getFather (), family.getMother ()]: + if not spouse: continue - - if parent.birth.getDate () != "": - d = SingleDate (parent.birth.getDateObj (). + if spouse == self: + continue + if spouse.birth.getDate () != "": + d = SingleDate (spouse.birth.getDateObj(). get_start_date ()) - d.setYear (d.getYear () + min_generation) - print d.getYear () + d.setYear (d.getYear () + max_age_difference) if not not_too_old (d): return 0 - if parent.death.getDate () != "": - d = SingleDate (parent.death.getDateObj (). + if spouse.death.getDate () != "": + d = SingleDate (spouse.birth.getDateObj(). get_start_date ()) + d.setYear (d.getYear () - min_generation) if not not_too_old (d): return 0 + if parents_too_old (spouse, max_age_difference): + return 0 + return 1 class Event(DataObj):