* src/Utils.py (probably_alive): Added two more checks for birth and death year

svn: r4322
This commit is contained in:
Martin Hawlisch 2005-04-08 09:40:15 +00:00
parent 62f20cb7b9
commit 985d1f5dc7
2 changed files with 19 additions and 1 deletions

View File

@ -1,3 +1,6 @@
2005-04-08 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/Utils.py (probably_alive): Added two more checks for birth and death year
2005-04-08 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2005-04-08 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/Utils.py (probably_alive): fix some bugs and added checking of ancestors. * src/Utils.py (probably_alive): fix some bugs and added checking of ancestors.

View File

@ -451,11 +451,13 @@ def probably_alive(person,db,current_year=None):
time_struct = time.localtime(time.time()) time_struct = time.localtime(time.time())
current_year = time_struct[0] current_year = time_struct[0]
death_year = None
# If the recorded death year is before current year then # If the recorded death year is before current year then
# things are simple. # things are simple.
if person.death_handle: if person.death_handle:
death = db.get_event_from_handle(person.death_handle) death = db.get_event_from_handle(person.death_handle)
if death.get_date_object().get_start_date() != Date.EMPTY: if death.get_date_object().get_start_date() != Date.EMPTY:
death_year = death.get_date_object().get_year()
if death.get_date_object().get_year() < current_year: if death.get_date_object().get_year() < current_year:
return False return False
@ -464,20 +466,33 @@ def probably_alive(person,db,current_year=None):
for ev_handle in person.event_list: for ev_handle in person.event_list:
ev = db.get_event_from_handle(ev_handle) ev = db.get_event_from_handle(ev_handle)
if ev and ev.name in ["Cause Of Death", "Burial", "Cremation"]: if ev and ev.name in ["Cause Of Death", "Burial", "Cremation"]:
if not death_year:
death_year = ev.get_date_object().get_year()
if ev.get_date_object().get_start_date() != Date.EMPTY: if ev.get_date_object().get_start_date() != Date.EMPTY:
if ev.get_date_object().get_year() < current_year: if ev.get_date_object().get_year() < current_year:
return False return False
birth_year = None
# If they were born within 100 years before current year then # If they were born within 100 years before current year then
# assume they are alive (we already know they are not dead). # assume they are alive (we already know they are not dead).
if person.birth_handle: if person.birth_handle:
birth = db.get_event_from_handle(person.birth_handle) birth = db.get_event_from_handle(person.birth_handle)
if birth.get_date_object().get_start_date() != Date.EMPTY: if birth.get_date_object().get_start_date() != Date.EMPTY:
if not birth_year:
birth_year = birth.get_date_object().get_year()
if birth.get_date_object().get_year() > current_year:
# person is not yet born
return False
r = not_too_old(birth.get_date_object(),current_year) r = not_too_old(birth.get_date_object(),current_year)
if r: if r:
#print person.get_primary_name().get_name(), " is alive because they were born late enough." #print person.get_primary_name().get_name(), " is alive because they were born late enough."
return True return True
if not birth_year and death_year:
if death_year > current_year + 110:
# person died more tha 110 after current year
return False
# Neither birth nor death events are available. Try looking # Neither birth nor death events are available. Try looking