2005-04-06 Richard Taylor <rjt-gramps@thegrindstone.me.uk>

* 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
This commit is contained in:
Richard Taylor 2005-04-06 15:52:52 +00:00
parent 4aa708e30e
commit 76c44f2694
3 changed files with 18 additions and 9 deletions

View File

@ -1,3 +1,7 @@
2005-04-06 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* 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 <rjt-gramps@thegrindstone.me.uk>
* src/plugins/FilterEditor.py: Added source IDs into the source combobox.

View File

@ -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"

View File

@ -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)