class IsSpouseOfFilterMatch(Rule): """Rule that checks for a person married to someone matching a filter""" labels = [_('Filter name:')] name = _('Spouses of <filter> match') description = _("Matches people married to anybody matching a filter") category = _('Family filters') def prepare(self, db): self.filt = MatchesFilter(self.list) self.filt.requestprepare(db) def apply(self, db, person): for family_handle in person.get_family_handle_list(): family = db.get_family_from_handle(family_handle) if family: for spouse_id in [ family.get_father_handle(), family.get_mother_handle() ]: if not spouse_id: continue if spouse_id == person.handle: continue if self.filt.apply(db, db.get_person_from_handle(spouse_id)): return True return False def reset(self): self.filt.requestreset()
def prepare(self, db): self.db = db self.map = set() filt = MatchesFilter(self.list) filt.requestprepare(db) for person in db.iter_people(): if filt.apply(db, person): self.init_list(person) filt.requestreset()
def prepare(self, db): self.db = db self.map = set() try: if int(self.list[1]): first = 0 else: first = 1 except IndexError: first = 1 filt = MatchesFilter(self.list[0:1]) filt.requestprepare(db) for person in db.iter_people(): if filt.apply(db, person): self.init_list(person, first) filt.requestreset()
def prepare(self, db): self.db = db # For each(!) person we keep track of who their ancestors # are, in a set(). So we only have to compute a person's # ancestor list once. # Start with filling the cache for root person (gramps_id in self.list[0]) self.ancestor_cache = {} self.with_people = [] filt = MatchesFilter(self.list) filt.requestprepare(db) for handle in db.iter_person_handles(): person = db.get_person_from_handle(handle) if person and filt.apply(db, person): #store all people in the filter so as to compare later self.with_people.append(person.handle) #fill list of ancestor of person if not present yet if handle not in self.ancestor_cache: self.add_ancs(db, person) filt.requestreset()