From aad34c7fbfdd62d8a5361c4a8d7e091bf43563e6 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Thu, 8 Dec 2005 22:52:21 +0000 Subject: [PATCH] * src/Utils.py (probably_alive): return False if any event of the person happened over 150 years ago; (too_old): add function; (not_too_old): require definite year for a positive decision. svn: r5508 --- gramps2/ChangeLog | 6 ++++++ gramps2/src/Utils.py | 24 +++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 440265545..b68f58e2a 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,9 @@ +2005-12-08 Alex Roitman + * src/Utils.py (probably_alive): return False if any event + of the person happened over 150 years ago; (too_old): add + function; (not_too_old): require definite year for a positive + decision. + 2005-12-07 Eero Tamminen * src/po/fi.po: Translation update to latest template diff --git a/gramps2/src/Utils.py b/gramps2/src/Utils.py index 1517cbda7..a68a1ddfc 100644 --- a/gramps2/src/Utils.py +++ b/gramps2/src/Utils.py @@ -538,6 +538,10 @@ def probably_alive(person,db,current_year=None,limit=0): if ev.get_date_object().get_start_date() != Date.EMPTY: if ev.get_date_object().get_year() - limit < current_year: return False + # For any other event of this person, check whether it happened + # too long ago. If so then the person is likely dead now. + elif ev and too_old(ev.get_date_object(),current_year): + return False if not current_year: time_struct = time.localtime(time.time()) @@ -551,8 +555,11 @@ def probably_alive(person,db,current_year=None,limit=0): if birth.get_date_object().get_start_date() != Date.EMPTY: if not birth_year: birth_year = birth.get_date_object().get_year() - r = not_too_old(birth.get_date_object(),current_year) - if r: + # Check whether the birth event is too old because the + # code above did not look at birth, only at other events + if too_old(birth.get_date_object(),current_year): + return False + if not_too_old(birth.get_date_object(),current_year): return True if not birth_year and death_year: @@ -682,7 +689,18 @@ def not_too_old(date,current_year=None): year = date.get_year() if year > current_year: return False - return not( year != 0 and current_year - year > 110) + return (year != 0 and current_year - year < 110) + +def too_old(date,current_year=None): + if current_year: + the_current_year = current_year + else: + time_struct = time.localtime(time.time()) + the_current_year = time_struct[0] + year = date.get_year() + if year > the_current_year: + return True + return (year != 0 and the_current_year - year > 150) #------------------------------------------------------------------------- #