* src/AddMedia.py: pychecker fixes
* src/DbPrompter.py: pychecker fixes * src/DisplayModels.py: pychecker fixes * src/GrampsDbBase.py: pychecker fixes * src/GrampsInMemDB.py: pychecker fixes * src/RelLib.py: move probably_alive to Utils * src/Utils.py: added probably_alive * src/WriteGedcom.py: probably_alive fixes * src/WriteGedcom.py: probably_alive fixes * src/plugins/WebPage.py: probably_alive fixes * src/plugins/WebFtree.py: probably_alive fixes * src/plugins/WebGeneWeb.py: probably_alive fixes svn: r3607
This commit is contained in:
@@ -550,6 +550,120 @@ def create_id():
|
||||
val = int(val/36)
|
||||
return s
|
||||
|
||||
|
||||
def probably_alive(person,db):
|
||||
"""Returns true if the person may be alive."""
|
||||
if person.death_handle:
|
||||
return False
|
||||
|
||||
# Look for Cause Of Death, Burial or Cremation events.
|
||||
# These are fairly good indications that someone's not alive.
|
||||
for ev_handle in person.event_list:
|
||||
ev = db.get_event_from_handle(ev_handle)
|
||||
if ev.name in ["Cause Of Death", "Burial", "Cremation"]:
|
||||
return False
|
||||
|
||||
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())
|
||||
|
||||
# Neither birth nor death events are available. Try looking
|
||||
# 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_handle in person.get_family_handle_list():
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
for child_handle in family.get_child_handle_list():
|
||||
child = db.get_person_from_handle(child_handle)
|
||||
if child.birth_handle:
|
||||
child_birth = db.get_event_from_handle(child.birth_handle)
|
||||
dobj = child_birth.get_date_object()
|
||||
if dobj.get_start_date() != Date.EMPTY:
|
||||
d = Date(dobj)
|
||||
d.set_year(d.get_year() - years)
|
||||
if not not_too_old (d):
|
||||
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):
|
||||
return True
|
||||
|
||||
if descendants_too_old (child, years + min_generation):
|
||||
return True
|
||||
|
||||
if descendants_too_old (person, min_generation):
|
||||
return False
|
||||
|
||||
return False
|
||||
|
||||
# What about their parents?
|
||||
|
||||
def parents_too_old (person, age_difference):
|
||||
family_handle = person.get_main_parents_family_handle()
|
||||
if family_handle:
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
for parent_id in [family.get_father_handle(), family.get_mother_handle()]:
|
||||
if not parent_id:
|
||||
continue
|
||||
|
||||
parent = db.get_person_from_handle(parent_id)
|
||||
if parent.birth_handle:
|
||||
parent_birth = db.get_event_from_handle(parent.birth_handle)
|
||||
if parent_birth.get_date():
|
||||
d = SingleDate (parent_birth.get_date_object().get_start_date())
|
||||
d.set_year (d.get_year() + max_generation + age_difference)
|
||||
if not not_too_old (d):
|
||||
return True
|
||||
|
||||
if parent.death_handle:
|
||||
parent_death = db.get_event_from_handle(parent.death_handle)
|
||||
if parent_death.get_date() != "":
|
||||
d = SingleDate (parent_death.get_date_object().get_start_date())
|
||||
d.set_year (d.get_year() + age_difference)
|
||||
if not not_too_old (d):
|
||||
return True
|
||||
|
||||
if parents_too_old (person, 0):
|
||||
return False
|
||||
|
||||
# As a last resort, trying seeing if their spouse's age gives
|
||||
# any clue.
|
||||
for family_handle in person.get_family_handle_list():
|
||||
family = db.get_family_from_handle(family_handle)
|
||||
for spouse_id in [family.get_father_handle(), family.get_mother_handle()]:
|
||||
if not spouse_id or spouse_id == person.handle:
|
||||
continue
|
||||
spouse = db.get_person_from_handle(spouse_id)
|
||||
sp_birth_handle = spouse.get_birth_handle()
|
||||
sp_death_handle = spouse.get_death_handle()
|
||||
if sp_birth_handle:
|
||||
spouse_birth = db.get_event_from_handle(sp_birth_handle)
|
||||
if spouse_birth.get_date() != "":
|
||||
d = SingleDate (spouse_birth.get_date_object().get_start_date())
|
||||
d.set_year (d.get_year() + max_age_difference)
|
||||
if not not_too_old (d):
|
||||
return False
|
||||
|
||||
if sp_death_handle:
|
||||
spouse_death = db.get_event_from_handle(sp_death_handle)
|
||||
if spouse_death.get_date() != "":
|
||||
d = SingleDate (spouse_death.get_date_object().get_start_date())
|
||||
d.set_year (d.get_year() - min_generation)
|
||||
if not not_too_old (d):
|
||||
return False
|
||||
|
||||
if parents_too_old (spouse, max_age_difference):
|
||||
return False
|
||||
return True
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user