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,6 +75,7 @@ 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():
|
||||||
|
if child_ref:
|
||||||
possibly_add_handle(child_ref.get_reference_handle())
|
possibly_add_handle(child_ref.get_reference_handle())
|
||||||
|
|
||||||
return people
|
return people
|
||||||
|
@ -48,6 +48,7 @@ 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)
|
||||||
|
if family:
|
||||||
for event_ref in family.get_event_ref_list():
|
for event_ref in family.get_event_ref_list():
|
||||||
if event_ref:
|
if event_ref:
|
||||||
event = db.get_event_from_handle(event_ref.ref)
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
|
@ -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,6 +68,7 @@ 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)
|
||||||
|
if fam:
|
||||||
for par_handle in (fam.get_father_handle(), fam.get_mother_handle()):
|
for par_handle in (fam.get_father_handle(), fam.get_mother_handle()):
|
||||||
if par_handle:
|
if par_handle:
|
||||||
par = db.get_person_from_handle(par_handle)
|
par = db.get_person_from_handle(par_handle)
|
||||||
|
@ -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,7 +53,10 @@ 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():
|
||||||
|
if attr:
|
||||||
name_match = self.list[0] == attr.get_type()
|
name_match = self.list[0] == attr.get_type()
|
||||||
value_match = \
|
value_match = \
|
||||||
attr.get_value().upper().find(self.list[1].upper()) != -1
|
attr.get_value().upper().find(self.list[1].upper()) != -1
|
||||||
|
@ -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,6 +61,7 @@ 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)
|
||||||
|
if f:
|
||||||
cnt = cnt + len(f.get_child_ref_list())
|
cnt = cnt + len(f.get_child_ref_list())
|
||||||
if self.list[1] and specified_type == f.get_relationship():
|
if self.list[1] and specified_type == f.get_relationship():
|
||||||
rel_type = 1
|
rel_type = 1
|
||||||
|
@ -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,6 +48,7 @@ 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)
|
||||||
|
if family:
|
||||||
ref = [ ref for ref in family.get_child_ref_list() \
|
ref = [ ref for ref in family.get_child_ref_list() \
|
||||||
if ref.ref == person.handle]
|
if ref.ref == person.handle]
|
||||||
if ref[0].get_father_relation() == ChildRefType.ADOPTED \
|
if ref[0].get_father_relation() == ChildRefType.ADOPTED \
|
||||||
|
@ -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)
|
||||||
|
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())
|
||||||
|
@ -83,9 +83,10 @@ 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
|
# Add every child recursively
|
||||||
for child_ref in family.get_child_ref_list():
|
for child_ref in family.get_child_ref_list():
|
||||||
|
if child_ref:
|
||||||
self.add_matches(self.db.get_person_from_handle(child_ref.ref))
|
self.add_matches(self.db.get_person_from_handle(child_ref.ref))
|
||||||
|
|
||||||
# Add spouse
|
# Add spouse
|
||||||
@ -101,6 +102,7 @@ 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 family:
|
||||||
if self.root_person.handle == family.get_father_handle():
|
if self.root_person.handle == family.get_father_handle():
|
||||||
spouse_handle = family.get_mother_handle()
|
spouse_handle = family.get_mother_handle()
|
||||||
else:
|
else:
|
||||||
|
@ -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)
|
||||||
|
if fam:
|
||||||
for child_ref in fam.get_child_ref_list():
|
for child_ref in fam.get_child_ref_list():
|
||||||
self.init_list(
|
self.init_list(
|
||||||
self.db.get_person_from_handle(child_ref.ref), gen+1)
|
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)
|
||||||
|
if fam:
|
||||||
for child_ref in fam.get_child_ref_list():
|
for child_ref in fam.get_child_ref_list():
|
||||||
self.init_list(
|
self.init_list(
|
||||||
self.db.get_person_from_handle(child_ref.ref), gen+1)
|
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)
|
||||||
|
if fam:
|
||||||
self.map.update(parent_id
|
self.map.update(parent_id
|
||||||
for parent_id in [fam.get_father_handle(), fam.get_mother_handle()]
|
for parent_id in [fam.get_father_handle(),
|
||||||
|
fam.get_mother_handle()]
|
||||||
if parent_id)
|
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,7 +55,9 @@ 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:
|
||||||
|
for spouse_id in [family.get_father_handle(),
|
||||||
|
family.get_mother_handle()]:
|
||||||
if not spouse_id:
|
if not spouse_id:
|
||||||
continue
|
continue
|
||||||
if spouse_id == person.handle:
|
if spouse_id == person.handle:
|
||||||
|
@ -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,6 +53,7 @@ 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)
|
||||||
|
if family:
|
||||||
father_handle = family.get_father_handle()
|
father_handle = family.get_father_handle()
|
||||||
mother_handle = family.get_mother_handle()
|
mother_handle = family.get_mother_handle()
|
||||||
if not father_handle:
|
if not father_handle:
|
||||||
|
Loading…
Reference in New Issue
Block a user