* src/FamilyView.py: try to prevent adding a spouse that has

already been added
* src/ReadXML.py: prevent adding a spouse that has already been
added
* src/plugins/Check.py: remove identical families in family list


svn: r4971
This commit is contained in:
Don Allingham 2005-07-28 02:20:31 +00:00
parent 52d06de491
commit ff5a31634c
4 changed files with 54 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2005-07-27 Don Allingham <don@gramps-project.org>
* src/FamilyView.py: try to prevent adding a spouse that has
already been added
* src/ReadXML.py: prevent adding a spouse that has already been
added
* src/plugins/Check.py: remove identical families in family list
2005-07-26 Alex Roitman <shura@gramps-project.org>
* src/ChooseParents.py (save_parents_clicked): Do not create
family if parent is self.

View File

@ -709,6 +709,9 @@ class FamilyView:
family.set_handle(fhandle)
family.set_gramps_id(self.parent.db.find_next_family_gramps_id())
if fhandle in old_person.get_family_handle_list():
return
old_person.add_family_handle(fhandle)
new_person.add_family_handle(fhandle)

View File

@ -754,6 +754,8 @@ class GrampsParser:
family = self.db.find_family_from_handle(attrs['hlink'],self.trans)
except KeyError:
family = self.find_family_by_gramps_id(self.map_fid(attrs["ref"]))
if attrs["ref"] == "F60":
print family.get_handle(),self.person.get_gramps_id()
self.person.add_family_handle(family.get_handle())
def start_name(self,attrs):

View File

@ -29,6 +29,7 @@
#-------------------------------------------------------------------------
import os
import cStringIO
import sets
from gettext import gettext as _
#-------------------------------------------------------------------------
@ -77,6 +78,7 @@ def runTool(database,active_person,callback,parent=None):
checker.check_for_broken_family_links()
checker.check_parent_relationships()
checker.cleanup_empty_families(0)
checker.cleanup_duplicate_spouses()
total = checker.family_errors()
@ -110,6 +112,7 @@ class CheckIntegrity:
self.removed_photo = []
self.empty_family = []
self.broken_links = []
self.duplicate_links = []
self.broken_parent_links = []
self.fam_rel = []
self.invalid_events = []
@ -119,7 +122,25 @@ class CheckIntegrity:
self.invalid_source_references = []
def family_errors(self):
return len(self.broken_parent_links) + len(self.broken_links) + len(self.empty_family)
return len(self.broken_parent_links) + len(self.broken_links) + len(self.empty_family) + len(self.duplicate_links)
def cleanup_duplicate_spouses(self):
cursor = self.db.get_person_cursor()
data = cursor.first()
while data:
(handle,value) = data
p = RelLib.Person(value)
splist = p.get_family_handle_list()
if len(splist) != len(sets.Set(splist)):
new_list = []
for value in splist:
if value not in new_list:
new_list.append(value)
self.duplicate_links.append((handle,value))
p.set_family_handle_list(new_list)
self.db.commit_person(p,self.trans)
data = cursor.next()
cursor.close()
def check_for_broken_family_links(self):
# Check persons referenced by the family objects
@ -556,6 +577,7 @@ class CheckIntegrity:
efam = len(self.empty_family)
blink = len(self.broken_links)
plink = len(self.broken_parent_links)
slink = len(self.duplicate_links)
rel = len(self.fam_rel)
event_invalid = len(self.invalid_events)
birth_invalid = len(self.invalid_birth_events)
@ -615,6 +637,25 @@ class CheckIntegrity:
self.text.write('\t')
self.text.write(_("%s was restored to the family of %s\n") % (cn,pn))
if slink > 0:
if slink == 1:
self.text.write(_("1 duplicate spouse/family link was found\n"))
else:
self.text.write(_("%d duplicate spouse/family links were found\n") % slink)
for (person_handle,family_handle) in self.broken_parent_links:
person = self.db.get_person_from_handle(person_handle)
if person:
cn = person.get_primary_name().get_name()
else:
cn = _("Non existing person")
family = self.db.get_family_from_handle(family_handle)
if family:
pn = Utils.family_name(family,self.db)
else:
pn = family.gramps_id
self.text.write('\t')
self.text.write(_("%s was restored to the family of %s\n") % (cn,pn))
if efam == 1:
self.text.write(_("1 empty family was found\n"))
elif efam > 1: