diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index 83c3c7fde..8e7711f3c 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,7 @@ +2005-05-01 Don Allingham + * src/plugins/Check.py: delete families that contain only a + single parent and no children + 2005-05-01 Eero Tamminen * src/dates/Date_fi.py: Fixed Display class + other changes. Parser is waiting for Gramps DateParser.py update diff --git a/gramps2/src/plugins/Check.py b/gramps2/src/plugins/Check.py index 085e5d0bf..20f8fa582 100644 --- a/gramps2/src/plugins/Check.py +++ b/gramps2/src/plugins/Check.py @@ -68,7 +68,7 @@ def runTool(database,active_person,callback,parent=None): while prev_total != total: prev_total = total - + checker.check_for_broken_family_links() checker.check_parent_relationships() checker.cleanup_empty_families(0) @@ -294,9 +294,27 @@ class CheckIntegrity: def cleanup_empty_families(self,automatic): for family_handle in self.db.get_family_handles(): family = self.db.get_family_from_handle(family_handle) - if not family.get_father_handle() and not family.get_mother_handle(): + father_handle = family.get_father_handle() + mother_handle = family.get_mother_handle() + + if not father_handle and not mother_handle: self.empty_family.append(family_handle) self.delete_empty_family(family_handle) + continue + elif not father_handle and len(family.get_child_handle_list()) == 0: + person = self.db.get_person_from_handle(mother_handle) + person.remove_family_handle(family_handle) + self.db.commit_person(person,self.trans) + self.db.remove_family(family_handle,self.trans) + self.empty_family.append(family_handle) + continue + elif not mother_handle and len(family.get_child_handle_list()) == 0: + person = self.db.get_person_from_handle(father_handle) + person.remove_family_handle(family_handle) + self.db.commit_person(person,self.trans) + self.db.remove_family(family_handle,self.trans) + self.empty_family.append(family_handle) + continue def delete_empty_family(self,family_handle): for key in self.db.get_person_handles(sort_handles=False):