From 996bc358ae222d861f7022bdc314a92f0bcbb1ba Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Wed, 13 Jul 2005 15:13:09 +0000 Subject: [PATCH] * src/GenericFilter.py: Proper test for place in event-based filters. svn: r4922 --- gramps2/ChangeLog | 3 +++ gramps2/src/GenericFilter.py | 50 ++++++++++++++++++++++-------------- 2 files changed, 34 insertions(+), 19 deletions(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index ba8e4c67f..e4c8a16f2 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,6 @@ +2005-07-13 Alex Roitman + * src/GenericFilter.py: Proper test for place in event-based filters. + 2005-07-13 Don Allingham * src/GrampsInMemDB.py: add get_event_cursor * src/GrampsDbBase.py: add get_event_cursor diff --git a/gramps2/src/GenericFilter.py b/gramps2/src/GenericFilter.py index 069ce6f15..d3975db82 100644 --- a/gramps2/src/GenericFilter.py +++ b/gramps2/src/GenericFilter.py @@ -999,7 +999,7 @@ class HasEvent(Rule): description = _("Matches people with a personal event of a particular value") category = _('Event filters') - def prepare(self,list): + def prepare(self,db): self.date = None try: if self.list and self.list[1]: @@ -1048,7 +1048,7 @@ class HasFamilyEvent(Rule): description = _("Matches people with a family event of a particular value") category = _('Event filters') - def prepare(self,list): + def prepare(self,db): self.date = None try: if self.list and self.list[1]: @@ -1071,12 +1071,16 @@ class HasFamilyEvent(Rule): if self.date: if date_cmp(self.date,event.get_date_object()): val = 0 - pl_id = event.get_place_handle() - if pl_id: - pl = db.get_place_from_handle(pl_id) - pn = pl.get_title() - if self.list[2] and pn.find(self.list[2].upper()) == -1: + if self.list[2]: + pl_id = event.get_place_handle() + if pl_id: + pl = db.get_place_from_handle(pl_id) + pn = pl.get_title().upper() + if pn.find(self.list[2].upper()) == -1: + val = 0 + else: val = 0 + if val == 1: return True return False @@ -1158,16 +1162,20 @@ class HasBirth(Rule): return False event = db.get_event_from_handle(event_handle) ed = event.get_description().upper() - if len(self.list) > 2 and ed.find(self.list[2].upper())==-1: + if len(self.list) > 2 and self.list[2] \ + and ed.find(self.list[2].upper())==-1: return False if self.date: if date_cmp(self.date,event.get_date_object()) == 0: return False - pl_id = event.get_place_handle() - if pl_id: - pl = db.get_place_from_handle(pl_id) - pn = pl.get_title() - if len(self.list) > 1 and pn.find(self.list[1].upper()) == -1: + if len(self.list)>1 and self.list[1]: + pl_id = event.get_place_handle() + if pl_id: + pl = db.get_place_from_handle(pl_id) + pn = pl.get_title().upper + if pn.find(self.list[1].upper()) == -1: + return False + else: return False return True @@ -1197,16 +1205,20 @@ class HasDeath(Rule): return False event = db.get_event_from_handle(event_handle) ed = event.get_description().upper() - if self.list[2] and ed.find(self.list[2].upper())==-1: + if len(self.list)>2 and self.list[2] \ + and ed.find(self.list[2].upper())==-1: return False if self.date: if date_cmp(self.date,event.get_date_object()) == 0: return False - pl_id = event.get_place_handle() - if pl_id: - pl = db.get_place_from_handle(pl_id) - pn = pl.get_title() - if self.list[1] and pn.find(self.list[1].upper()) == -1: + if len(self.list)>1 and self.list[1]: + pl_id = event.get_place_handle() + if pl_id: + pl = db.get_place_from_handle(pl_id) + pn = pl.get_title().upper() + if self.list[1] and pn.find(self.list[1].upper()) == -1: + return False + else: return False return True