3943: Crashed whilst exporting to data.gramps using a person filter 'Public'; fixed many filter rules for people
svn: r15369
This commit is contained in:
parent
14f3d33da4
commit
9fd5722f96
@ -75,7 +75,8 @@ def get_family_handle_people(db, exclude_handle, family_handle):
|
|||||||
possibly_add_handle(family.get_mother_handle())
|
possibly_add_handle(family.get_mother_handle())
|
||||||
|
|
||||||
for child_ref in family.get_child_ref_list():
|
for child_ref in family.get_child_ref_list():
|
||||||
possibly_add_handle(child_ref.get_reference_handle())
|
if child_ref:
|
||||||
|
possibly_add_handle(child_ref.get_reference_handle())
|
||||||
|
|
||||||
return people
|
return people
|
||||||
|
|
||||||
|
@ -48,11 +48,12 @@ class FamilyWithIncompleteEvent(Rule):
|
|||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for family_handle in person.get_family_handle_list():
|
for family_handle in person.get_family_handle_list():
|
||||||
family = db.get_family_from_handle(family_handle)
|
family = db.get_family_from_handle(family_handle)
|
||||||
for event_ref in family.get_event_ref_list():
|
if family:
|
||||||
if event_ref:
|
for event_ref in family.get_event_ref_list():
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
if event_ref:
|
||||||
if not event.get_place_handle():
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
return True
|
if not event.get_place_handle():
|
||||||
if not event.get_date_object():
|
return True
|
||||||
return True
|
if not event.get_date_object():
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -58,7 +58,9 @@ class HasBirth(Rule):
|
|||||||
|
|
||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for event_ref in person.get_event_ref_list():
|
for event_ref in person.get_event_ref_list():
|
||||||
if event_ref.role != EventRoleType.PRIMARY:
|
if not event_ref:
|
||||||
|
continue
|
||||||
|
elif event_ref.role != EventRoleType.PRIMARY:
|
||||||
# Only match primaries, no witnesses
|
# Only match primaries, no witnesses
|
||||||
continue
|
continue
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
@ -68,14 +68,15 @@ class HasCommonAncestorWith(Rule):
|
|||||||
|
|
||||||
for fam_handle in person.get_parent_family_handle_list():
|
for fam_handle in person.get_parent_family_handle_list():
|
||||||
fam = db.get_family_from_handle(fam_handle)
|
fam = db.get_family_from_handle(fam_handle)
|
||||||
for par_handle in (fam.get_father_handle(), fam.get_mother_handle()):
|
if fam:
|
||||||
if par_handle:
|
for par_handle in (fam.get_father_handle(), fam.get_mother_handle()):
|
||||||
par = db.get_person_from_handle(par_handle)
|
if par_handle:
|
||||||
if par and par.handle not in self.ancestor_cache:
|
par = db.get_person_from_handle(par_handle)
|
||||||
self.add_ancs(db, par)
|
if par and par.handle not in self.ancestor_cache:
|
||||||
if par:
|
self.add_ancs(db, par)
|
||||||
self.ancestor_cache[person.handle].add(par)
|
if par:
|
||||||
self.ancestor_cache[person.handle] |= self.ancestor_cache[par.handle]
|
self.ancestor_cache[person.handle].add(par)
|
||||||
|
self.ancestor_cache[person.handle] |= self.ancestor_cache[par.handle]
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
self.ancestor_cache = {}
|
self.ancestor_cache = {}
|
||||||
|
@ -58,7 +58,9 @@ class HasDeath(Rule):
|
|||||||
|
|
||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for event_ref in person.get_event_ref_list():
|
for event_ref in person.get_event_ref_list():
|
||||||
if event_ref.role != EventRoleType.PRIMARY:
|
if not event_ref:
|
||||||
|
continue
|
||||||
|
elif event_ref.role != EventRoleType.PRIMARY:
|
||||||
# Only match primaries, no witnesses
|
# Only match primaries, no witnesses
|
||||||
continue
|
continue
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
@ -53,10 +53,13 @@ class HasFamilyAttribute(Rule):
|
|||||||
return False
|
return False
|
||||||
for f_id in person.get_family_handle_list():
|
for f_id in person.get_family_handle_list():
|
||||||
f = db.get_family_from_handle(f_id)
|
f = db.get_family_from_handle(f_id)
|
||||||
|
if not f:
|
||||||
|
continue
|
||||||
for attr in f.get_attribute_list():
|
for attr in f.get_attribute_list():
|
||||||
name_match = self.list[0] == attr.get_type()
|
if attr:
|
||||||
value_match = \
|
name_match = self.list[0] == attr.get_type()
|
||||||
attr.get_value().upper().find(self.list[1].upper()) != -1
|
value_match = \
|
||||||
if name_match and value_match:
|
attr.get_value().upper().find(self.list[1].upper()) != -1
|
||||||
return True
|
if name_match and value_match:
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -64,6 +64,8 @@ class HasFamilyEvent(Rule):
|
|||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for f_id in person.get_family_handle_list():
|
for f_id in person.get_family_handle_list():
|
||||||
f = db.get_family_from_handle(f_id)
|
f = db.get_family_from_handle(f_id)
|
||||||
|
if not f:
|
||||||
|
continue
|
||||||
for event_ref in f.get_event_ref_list():
|
for event_ref in f.get_event_ref_list():
|
||||||
if not event_ref:
|
if not event_ref:
|
||||||
continue
|
continue
|
||||||
|
@ -61,9 +61,10 @@ class HasRelationship(Rule):
|
|||||||
# count children and look for a relationship type match
|
# count children and look for a relationship type match
|
||||||
for f_id in person.get_family_handle_list():
|
for f_id in person.get_family_handle_list():
|
||||||
f = db.get_family_from_handle(f_id)
|
f = db.get_family_from_handle(f_id)
|
||||||
cnt = cnt + len(f.get_child_ref_list())
|
if f:
|
||||||
if self.list[1] and specified_type == f.get_relationship():
|
cnt = cnt + len(f.get_child_ref_list())
|
||||||
rel_type = 1
|
if self.list[1] and specified_type == f.get_relationship():
|
||||||
|
rel_type = 1
|
||||||
|
|
||||||
# if number of relations specified
|
# if number of relations specified
|
||||||
if self.list[0]:
|
if self.list[0]:
|
||||||
|
@ -171,7 +171,7 @@ class HasTextMatchingSubstringOf(Rule):
|
|||||||
self.repo_map.update(
|
self.repo_map.update(
|
||||||
|
|
||||||
repo.handle for repo in self.db.iter_repositories()
|
repo.handle for repo in self.db.iter_repositories()
|
||||||
if self.match_object(repo)
|
if repo and self.match_object(repo)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,9 +48,10 @@ class HaveAltFamilies(Rule):
|
|||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for fhandle in person.get_parent_family_handle_list():
|
for fhandle in person.get_parent_family_handle_list():
|
||||||
family = db.get_family_from_handle(fhandle)
|
family = db.get_family_from_handle(fhandle)
|
||||||
ref = [ ref for ref in family.get_child_ref_list() \
|
if family:
|
||||||
if ref.ref == person.handle]
|
ref = [ ref for ref in family.get_child_ref_list() \
|
||||||
if ref[0].get_father_relation() == ChildRefType.ADOPTED \
|
if ref.ref == person.handle]
|
||||||
or ref[0].get_mother_relation() == ChildRefType.ADOPTED:
|
if ref[0].get_father_relation() == ChildRefType.ADOPTED \
|
||||||
return True
|
or ref[0].get_mother_relation() == ChildRefType.ADOPTED:
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -47,4 +47,4 @@ class HaveChildren(Rule):
|
|||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for family_handle in person.get_family_handle_list():
|
for family_handle in person.get_family_handle_list():
|
||||||
family = db.get_family_from_handle(family_handle)
|
family = db.get_family_from_handle(family_handle)
|
||||||
return len(family.get_child_ref_list()) > 0
|
return family and len(family.get_child_ref_list()) > 0
|
||||||
|
@ -69,5 +69,6 @@ class IsChildOfFilterMatch(MatchesFilter):
|
|||||||
return
|
return
|
||||||
for fam_id in person.get_family_handle_list():
|
for fam_id in person.get_family_handle_list():
|
||||||
fam = self.db.get_family_from_handle(fam_id)
|
fam = self.db.get_family_from_handle(fam_id)
|
||||||
self.map.update(child_ref.ref
|
if fam:
|
||||||
for child_ref in fam.get_child_ref_list())
|
self.map.update(child_ref.ref
|
||||||
|
for child_ref in fam.get_child_ref_list())
|
||||||
|
@ -83,17 +83,18 @@ class IsDescendantFamilyOf(Rule):
|
|||||||
|
|
||||||
for family_handle in person.get_family_handle_list():
|
for family_handle in person.get_family_handle_list():
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
family = self.db.get_family_from_handle(family_handle)
|
||||||
|
if family:
|
||||||
|
# Add every child recursively
|
||||||
|
for child_ref in family.get_child_ref_list():
|
||||||
|
if child_ref:
|
||||||
|
self.add_matches(self.db.get_person_from_handle(child_ref.ref))
|
||||||
|
|
||||||
# Add every child recursively
|
# Add spouse
|
||||||
for child_ref in family.get_child_ref_list():
|
if person.handle == family.get_father_handle():
|
||||||
self.add_matches(self.db.get_person_from_handle(child_ref.ref))
|
spouse_handle = family.get_mother_handle()
|
||||||
|
else:
|
||||||
# Add spouse
|
spouse_handle = family.get_father_handle()
|
||||||
if person.handle == family.get_father_handle():
|
self.matches.add(spouse_handle)
|
||||||
spouse_handle = family.get_mother_handle()
|
|
||||||
else:
|
|
||||||
spouse_handle = family.get_father_handle()
|
|
||||||
self.matches.add(spouse_handle)
|
|
||||||
|
|
||||||
def exclude(self):
|
def exclude(self):
|
||||||
# This removes root person and his/her spouses from the matches set
|
# This removes root person and his/her spouses from the matches set
|
||||||
@ -101,8 +102,9 @@ class IsDescendantFamilyOf(Rule):
|
|||||||
self.matches.remove(self.root_person.handle)
|
self.matches.remove(self.root_person.handle)
|
||||||
for family_handle in self.root_person.get_family_handle_list():
|
for family_handle in self.root_person.get_family_handle_list():
|
||||||
family = self.db.get_family_from_handle(family_handle)
|
family = self.db.get_family_from_handle(family_handle)
|
||||||
if self.root_person.handle == family.get_father_handle():
|
if family:
|
||||||
spouse_handle = family.get_mother_handle()
|
if self.root_person.handle == family.get_father_handle():
|
||||||
else:
|
spouse_handle = family.get_mother_handle()
|
||||||
spouse_handle = family.get_father_handle()
|
else:
|
||||||
self.matches.remove(spouse_handle)
|
spouse_handle = family.get_father_handle()
|
||||||
|
self.matches.remove(spouse_handle)
|
||||||
|
@ -75,6 +75,7 @@ class IsLessThanNthGenerationDescendantOf(Rule):
|
|||||||
|
|
||||||
for fam_id in person.get_family_handle_list():
|
for fam_id in person.get_family_handle_list():
|
||||||
fam = self.db.get_family_from_handle(fam_id)
|
fam = self.db.get_family_from_handle(fam_id)
|
||||||
for child_ref in fam.get_child_ref_list():
|
if fam:
|
||||||
self.init_list(
|
for child_ref in fam.get_child_ref_list():
|
||||||
self.db.get_person_from_handle(child_ref.ref), gen+1)
|
self.init_list(
|
||||||
|
self.db.get_person_from_handle(child_ref.ref), gen+1)
|
||||||
|
@ -73,6 +73,7 @@ class IsMoreThanNthGenerationDescendantOf(Rule):
|
|||||||
|
|
||||||
for fam_id in person.get_family_handle_list():
|
for fam_id in person.get_family_handle_list():
|
||||||
fam = self.db.get_family_from_handle(fam_id)
|
fam = self.db.get_family_from_handle(fam_id)
|
||||||
for child_ref in fam.get_child_ref_list():
|
if fam:
|
||||||
self.init_list(
|
for child_ref in fam.get_child_ref_list():
|
||||||
self.db.get_person_from_handle(child_ref.ref), gen+1)
|
self.init_list(
|
||||||
|
self.db.get_person_from_handle(child_ref.ref), gen+1)
|
||||||
|
@ -67,6 +67,9 @@ class IsParentOfFilterMatch(MatchesFilter):
|
|||||||
def init_list(self,person):
|
def init_list(self,person):
|
||||||
for fam_id in person.get_parent_family_handle_list():
|
for fam_id in person.get_parent_family_handle_list():
|
||||||
fam = self.db.get_family_from_handle(fam_id)
|
fam = self.db.get_family_from_handle(fam_id)
|
||||||
self.map.update(parent_id
|
if fam:
|
||||||
for parent_id in [fam.get_father_handle(), fam.get_mother_handle()]
|
self.map.update(parent_id
|
||||||
if parent_id)
|
for parent_id in [fam.get_father_handle(),
|
||||||
|
fam.get_mother_handle()]
|
||||||
|
if parent_id)
|
||||||
|
|
||||||
|
@ -71,4 +71,4 @@ class IsSiblingOfFilterMatch(MatchesFilter):
|
|||||||
if fam:
|
if fam:
|
||||||
self.map.update(child_ref.ref
|
self.map.update(child_ref.ref
|
||||||
for child_ref in fam.get_child_ref_list()
|
for child_ref in fam.get_child_ref_list()
|
||||||
if child_ref.ref != person.handle)
|
if child_ref and child_ref.ref != person.handle)
|
||||||
|
@ -55,11 +55,13 @@ class IsSpouseOfFilterMatch(MatchesFilter):
|
|||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for family_handle in person.get_family_handle_list ():
|
for family_handle in person.get_family_handle_list ():
|
||||||
family = db.get_family_from_handle(family_handle)
|
family = db.get_family_from_handle(family_handle)
|
||||||
for spouse_id in [family.get_father_handle (), family.get_mother_handle ()]:
|
if family:
|
||||||
if not spouse_id:
|
for spouse_id in [family.get_father_handle(),
|
||||||
continue
|
family.get_mother_handle()]:
|
||||||
if spouse_id == person.handle:
|
if not spouse_id:
|
||||||
continue
|
continue
|
||||||
if self.filt.apply (db, db.get_person_from_handle( spouse_id)):
|
if spouse_id == person.handle:
|
||||||
return True
|
continue
|
||||||
|
if self.filt.apply (db, db.get_person_from_handle( spouse_id)):
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
@ -48,7 +48,7 @@ class IsWitness(Rule):
|
|||||||
|
|
||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
for event_ref in person.event_ref_list:
|
for event_ref in person.event_ref_list:
|
||||||
if event_ref.role == EventRoleType.WITNESS:
|
if event_ref and event_ref.role == EventRoleType.WITNESS:
|
||||||
# This is the witness.
|
# This is the witness.
|
||||||
# If event type was given, then check it.
|
# If event type was given, then check it.
|
||||||
if self.list[0]:
|
if self.list[0]:
|
||||||
|
@ -53,10 +53,11 @@ class MissingParent(Rule):
|
|||||||
return True
|
return True
|
||||||
for family_handle in person.get_parent_family_handle_list():
|
for family_handle in person.get_parent_family_handle_list():
|
||||||
family = db.get_family_from_handle(family_handle)
|
family = db.get_family_from_handle(family_handle)
|
||||||
father_handle = family.get_father_handle()
|
if family:
|
||||||
mother_handle = family.get_mother_handle()
|
father_handle = family.get_father_handle()
|
||||||
if not father_handle:
|
mother_handle = family.get_mother_handle()
|
||||||
return True
|
if not father_handle:
|
||||||
if not mother_handle:
|
return True
|
||||||
return True
|
if not mother_handle:
|
||||||
|
return True
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user