2006-11-09 Alex Roitman <shura@gramps-project.org>

* src/Filters/Rules/Person/_HasDeath.py (apply): Match any of the
	death events.
	* src/Filters/Rules/Person/_HasBirth.py (apply): Match any of the
	birth events.



svn: r7603
This commit is contained in:
Alex Roitman 2006-11-10 07:27:11 +00:00
parent c3b30caddc
commit 49199f9c12
3 changed files with 66 additions and 43 deletions

View File

@ -1,3 +1,9 @@
2006-11-09 Alex Roitman <shura@gramps-project.org>
* src/Filters/Rules/Person/_HasDeath.py (apply): Match any of the
death events.
* src/Filters/Rules/Person/_HasBirth.py (apply): Match any of the
birth events.
2006-11-09 Don Allingham <don@gramps-project.org> 2006-11-09 Don Allingham <don@gramps-project.org>
* src/DisplayModels/PageView.py: fix delete * src/DisplayModels/PageView.py: fix delete

View File

@ -33,6 +33,7 @@ from gettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import DateHandler import DateHandler
from RelLib import EventType
from Filters.Rules._Rule import Rule from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import loose_date_cmp from Filters.Rules._RuleUtils import loose_date_cmp
@ -57,24 +58,32 @@ class HasBirth(Rule):
self.date = None self.date = None
def apply(self,db,person): def apply(self,db,person):
event_ref = person.get_birth_ref() for event_ref in person.get_event_ref_list():
if not event_ref: event = db.get_event_from_handle(event_ref.ref)
return False if event.get_type() != EventType.BIRTH:
event = db.get_event_from_handle(event_ref.ref) # No match: wrong type
ed = event.get_description().upper() continue
if self.list[2] \ ed = event.get_description().upper()
and ed.find(self.list[2].upper())==-1: if self.list[2] \
return False and ed.find(self.list[2].upper())==-1:
if self.date: # No match: wrong description
if loose_date_cmp(self.date,event.get_date_object()) == 0: continue
return False if self.date:
if self.list[1]: if loose_date_cmp(self.date,event.get_date_object()) == 0:
pl_id = event.get_place_handle() # No match: wrong date
if pl_id: continue
pl = db.get_place_from_handle(pl_id) if self.list[1]:
pn = pl.get_title().upper() pl_id = event.get_place_handle()
if pn.find(self.list[1].upper()) == -1: if pl_id:
return False pl = db.get_place_from_handle(pl_id)
else: pn = pl.get_title().upper()
return False if pn.find(self.list[1].upper()) == -1:
return True # No match: wrong place
continue
else:
# No match: event has no place, but place specified
continue
# This event matched: exit positive
return True
# Nothing matched: exit negative
return False

View File

@ -33,6 +33,7 @@ from gettext import gettext as _
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import DateHandler import DateHandler
from RelLib import EventType
from Filters.Rules._Rule import Rule from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import loose_date_cmp from Filters.Rules._RuleUtils import loose_date_cmp
@ -57,25 +58,32 @@ class HasDeath(Rule):
self.date = None self.date = None
def apply(self,db,person): def apply(self,db,person):
event_ref = person.get_death_ref() for event_ref in person.get_event_ref_list():
if not event_ref: event = db.get_event_from_handle(event_ref.ref)
return False if event.get_type() != EventType.DEATH:
event_handle = event_ref.ref # No match: wrong type
event = db.get_event_from_handle(event_handle) continue
ed = event.get_description().upper() ed = event.get_description().upper()
if self.list[2] \ if self.list[2] \
and ed.find(self.list[2].upper())==-1: and ed.find(self.list[2].upper())==-1:
return False # No match: wrong description
if self.date: continue
if loose_date_cmp(self.date,event.get_date_object()) == 0: if self.date:
return False if loose_date_cmp(self.date,event.get_date_object()) == 0:
if self.list[1]: # No match: wrong date
pl_id = event.get_place_handle() continue
if pl_id: if self.list[1]:
pl = db.get_place_from_handle(pl_id) pl_id = event.get_place_handle()
pn = pl.get_title().upper() if pl_id:
if self.list[1] and pn.find(self.list[1].upper()) == -1: pl = db.get_place_from_handle(pl_id)
return False pn = pl.get_title().upper()
else: if pn.find(self.list[1].upper()) == -1:
return False # No match: wrong place
return True continue
else:
# No match: event has no place, but place specified
continue
# This event matched: exit positive
return True
# Nothing matched: exit negative
return False