From 76c44f269448cddd96d1a1f0b6950c154dbbe961 Mon Sep 17 00:00:00 2001 From: Richard Taylor Date: Wed, 6 Apr 2005 15:52:52 +0000 Subject: [PATCH] 2005-04-06 Richard Taylor * src/GenericFilter.py: added a current year parameter to probably alive rule. * src/Utils.py: added a current year parameter to probably alive function. svn: r4312 --- gramps2/ChangeLog | 4 ++++ gramps2/src/GenericFilter.py | 8 ++++++-- gramps2/src/Utils.py | 15 ++++++++------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index b89bef072..48ae37512 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2005-04-06 Richard Taylor + * src/GenericFilter.py: added a current year parameter to probably alive rule. + * src/Utils.py: added a current year parameter to probably alive function. + 2005-04-06 Richard Taylor * src/plugins/FilterEditor.py: Added source IDs into the source combobox. diff --git a/gramps2/src/GenericFilter.py b/gramps2/src/GenericFilter.py index df1470b25..7bfa77c98 100644 --- a/gramps2/src/GenericFilter.py +++ b/gramps2/src/GenericFilter.py @@ -1724,7 +1724,7 @@ class FamilyWithIncompleteEvent(Rule): class ProbablyAlive(Rule): """People probably alive""" - labels = [] + labels = ["On year"] def name(self): return 'People probably alive' @@ -1737,8 +1737,12 @@ class ProbablyAlive(Rule): def apply(self,db,p_id): + if len(self.list) == 0: + current_year = None + else: + current_year = int(self.list[0]) p = db.get_person_from_handle(p_id) - return probably_alive(p,db) + return probably_alive(p,db,current_year) #------------------------------------------------------------------------- # "People marked private" diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index c4cf26a83..491729ccf 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -438,7 +438,7 @@ def create_id(): return s -def probably_alive(person,db): +def probably_alive(person,db,current_year=None): """Returns true if the person may be alive.""" if person.death_handle: return False @@ -453,7 +453,7 @@ def probably_alive(person,db): if person.birth_handle: birth = db.get_event_from_handle(person.birth_handle) if birth.get_date_object().get_start_date() != Date.EMPTY: - return not_too_old(birth.get_date_object()) + return not_too_old(birth.get_date_object(),current_year) # Neither birth nor death events are available. Try looking # for descendants that were born more than a lifespan ago. @@ -475,14 +475,14 @@ def probably_alive(person,db): val = d.get_start_date() val = d.get_year() - years d.set_year(val) - if not not_too_old (d): + if not not_too_old (d,current_year): return True if child.death_handle: child_death = db.get_event_from_handle(child.death_handle) dobj = child_death.get_date_object() if dobj.get_start_date() != Date.EMPTY: - if not not_too_old (dobj): + if not not_too_old (dobj,current_year): return True if descendants_too_old (child, years + min_generation): @@ -492,9 +492,10 @@ def probably_alive(person,db): return False return False -def not_too_old(date): - time_struct = time.localtime(time.time()) - current_year = time_struct[0] +def not_too_old(date,current_year=None): + if not current_year: + time_struct = time.localtime(time.time()) + current_year = time_struct[0] year = date.get_year() return not( year != 0 and current_year - year > 110)