3106: Unable to use People with a common ancestor with <filter> match rule
svn: r13649
This commit is contained in:
parent
4189b78df3
commit
a477d5bc7d
@ -56,12 +56,15 @@ class HasCommonAncestorWith(Rule):
|
||||
# ancestor list once.
|
||||
# Start with filling the cache for root person (gramps_id in self.list[0])
|
||||
self.ancestor_cache = {}
|
||||
self.root_person = db.get_person_from_gramps_id(self.list[0])
|
||||
self.add_ancs(db, self.root_person)
|
||||
root_person = db.get_person_from_gramps_id(self.list[0])
|
||||
self.add_ancs(db, root_person)
|
||||
self.with_people = [root_person.handle]
|
||||
|
||||
def add_ancs(self, db, person):
|
||||
if person.handle not in self.ancestor_cache:
|
||||
self.ancestor_cache[person.handle] = set()
|
||||
else:
|
||||
return
|
||||
|
||||
for fam_handle in person.get_parent_family_handle_list():
|
||||
fam = db.get_family_from_handle(fam_handle)
|
||||
@ -78,8 +81,10 @@ class HasCommonAncestorWith(Rule):
|
||||
self.ancestor_cache = {}
|
||||
|
||||
def has_common_ancestor(self, other):
|
||||
if self.ancestor_cache[self.root_person.handle] & self.ancestor_cache[other.handle]:
|
||||
return True
|
||||
for handle in self.with_people:
|
||||
if self.ancestor_cache[handle] & \
|
||||
self.ancestor_cache[other.handle]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def apply(self, db, person):
|
||||
|
@ -55,12 +55,22 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith,MatchesFilter):
|
||||
HasCommonAncestorWith.__init__(self,list)
|
||||
self.ancestor_cache = {}
|
||||
|
||||
def init_ancestor_cache(self,db):
|
||||
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.prepare(db)
|
||||
def init(self, h): self.ancestor_cache[h] = 1
|
||||
for handle in db.iter_person_handles():
|
||||
if (handle not in self.ancestor_cache
|
||||
and filt.apply (db, db.get_person_from_handle(handle))):
|
||||
for_each_ancestor(db,[handle],init,self)
|
||||
person = db.get_person_from_handle(handle)
|
||||
if 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.reset()
|
||||
|
Loading…
Reference in New Issue
Block a user