3878: Private option and filter on Exporter --- protection from null person
svn: r15425
This commit is contained in:
parent
88a571d9e3
commit
8981551fcd
@ -57,11 +57,14 @@ class HasCommonAncestorWith(Rule):
|
|||||||
# Start with filling the cache for root person (gramps_id in self.list[0])
|
# Start with filling the cache for root person (gramps_id in self.list[0])
|
||||||
self.ancestor_cache = {}
|
self.ancestor_cache = {}
|
||||||
root_person = db.get_person_from_gramps_id(self.list[0])
|
root_person = db.get_person_from_gramps_id(self.list[0])
|
||||||
self.add_ancs(db, root_person)
|
if root_person:
|
||||||
self.with_people = [root_person.handle]
|
self.add_ancs(db, root_person)
|
||||||
|
self.with_people = [root_person.handle]
|
||||||
|
else:
|
||||||
|
self.with_people = []
|
||||||
|
|
||||||
def add_ancs(self, db, person):
|
def add_ancs(self, db, person):
|
||||||
if person.handle not in self.ancestor_cache:
|
if person and person.handle not in self.ancestor_cache:
|
||||||
self.ancestor_cache[person.handle] = set()
|
self.ancestor_cache[person.handle] = set()
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
@ -85,13 +88,13 @@ class HasCommonAncestorWith(Rule):
|
|||||||
for handle in self.with_people:
|
for handle in self.with_people:
|
||||||
if ((handle in self.ancestor_cache and
|
if ((handle in self.ancestor_cache and
|
||||||
self.ancestor_cache[handle]) &
|
self.ancestor_cache[handle]) &
|
||||||
(other.handle in self.ancestor_cache and
|
(other and other.handle in self.ancestor_cache and
|
||||||
self.ancestor_cache[other.handle])):
|
self.ancestor_cache[other.handle])):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def apply(self, db, person):
|
def apply(self, db, person):
|
||||||
if person.handle not in self.ancestor_cache:
|
if person and person.handle not in self.ancestor_cache:
|
||||||
self.add_ancs(db, person)
|
self.add_ancs(db, person)
|
||||||
|
|
||||||
return self.has_common_ancestor(person)
|
return self.has_common_ancestor(person)
|
||||||
|
@ -51,8 +51,8 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith,MatchesFilter):
|
|||||||
"with anybody matched by a filter")
|
"with anybody matched by a filter")
|
||||||
category = _("Ancestral filters")
|
category = _("Ancestral filters")
|
||||||
|
|
||||||
def __init__(self,list):
|
def __init__(self, list):
|
||||||
HasCommonAncestorWith.__init__(self,list)
|
HasCommonAncestorWith.__init__(self, list)
|
||||||
self.ancestor_cache = {}
|
self.ancestor_cache = {}
|
||||||
|
|
||||||
def prepare(self, db):
|
def prepare(self, db):
|
||||||
@ -67,7 +67,7 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith,MatchesFilter):
|
|||||||
filt.prepare(db)
|
filt.prepare(db)
|
||||||
for handle in db.iter_person_handles():
|
for handle in db.iter_person_handles():
|
||||||
person = db.get_person_from_handle(handle)
|
person = db.get_person_from_handle(handle)
|
||||||
if filt.apply (db, person):
|
if person and filt.apply(db, person):
|
||||||
#store all people in the filter so as to compare later
|
#store all people in the filter so as to compare later
|
||||||
self.with_people.append(person.handle)
|
self.with_people.append(person.handle)
|
||||||
#fill list of ancestor of person if not present yet
|
#fill list of ancestor of person if not present yet
|
||||||
|
Loading…
Reference in New Issue
Block a user