2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2004-01-18 07:29:30 +05:30
|
|
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
|
|
|
|
2004-01-18 07:29:30 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"Database Processing/Check and repair database"
|
|
|
|
|
2003-06-16 10:27:25 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import os
|
2003-04-16 11:55:38 +05:30
|
|
|
import cStringIO
|
2003-06-16 10:27:25 +05:30
|
|
|
import shutil
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gtk modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
2003-06-16 10:27:25 +05:30
|
|
|
# gtk modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import Utils
|
|
|
|
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2003-06-16 10:27:25 +05:30
|
|
|
from QuestionDialog import OkDialog, MissingMediaDialog
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
2003-06-16 10:27:25 +05:30
|
|
|
# runTool
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2004-05-11 05:20:30 +05:30
|
|
|
def runTool(database,active_person,callback,parent=None):
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
try:
|
2004-05-11 05:20:30 +05:30
|
|
|
checker = CheckIntegrity(database,parent)
|
2002-10-20 19:55:16 +05:30
|
|
|
checker.check_for_broken_family_links()
|
2003-05-21 23:36:41 +05:30
|
|
|
checker.cleanup_missing_photos(0)
|
2002-10-20 19:55:16 +05:30
|
|
|
checker.check_parent_relationships()
|
|
|
|
checker.cleanup_empty_families(0)
|
2003-05-19 10:24:14 +05:30
|
|
|
errs = checker.build_report(0)
|
|
|
|
if errs:
|
|
|
|
checker.report(0)
|
2002-10-20 19:55:16 +05:30
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
class CheckIntegrity:
|
|
|
|
|
2004-05-11 05:20:30 +05:30
|
|
|
def __init__(self,db,parent):
|
2002-10-20 19:55:16 +05:30
|
|
|
self.db = db
|
|
|
|
self.bad_photo = []
|
2003-05-14 08:16:59 +05:30
|
|
|
self.replaced_photo = []
|
|
|
|
self.removed_photo = []
|
2002-10-20 19:55:16 +05:30
|
|
|
self.empty_family = []
|
|
|
|
self.broken_links = []
|
|
|
|
self.broken_parent_links = []
|
|
|
|
self.fam_rel = []
|
|
|
|
|
|
|
|
def check_for_broken_family_links(self):
|
|
|
|
self.broken_links = []
|
2004-04-17 00:45:02 +05:30
|
|
|
for family_id in self.db.get_family_keys():
|
|
|
|
family = self.db.find_family_from_id(family_id)
|
2004-05-09 09:32:26 +05:30
|
|
|
father_id = family.get_father_id()
|
|
|
|
mother_id = family.get_mother_id()
|
|
|
|
if father_id:
|
|
|
|
father = self.db.find_person_from_id(father_id)
|
|
|
|
if mother_id:
|
|
|
|
mother = self.db.find_person_from_id(mother_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-09 09:32:26 +05:30
|
|
|
if father_id and family_id not in father.get_family_id_list():
|
|
|
|
self.broken_parent_links.append((father_id,family_id))
|
2004-04-17 00:45:02 +05:30
|
|
|
father.add_family_id(family_id)
|
|
|
|
self.db.commit_person(father)
|
2004-05-09 09:32:26 +05:30
|
|
|
if mother_id and family_id not in mother.get_family_id_list():
|
|
|
|
self.broken_parent_links.append((mother_id,family_id))
|
2004-04-17 00:45:02 +05:30
|
|
|
mother.add_family_id(family_id)
|
|
|
|
self.db.commit_person(mother)
|
|
|
|
for child_id in family.get_child_id_list():
|
|
|
|
child = self.db.find_person_from_id(child_id)
|
2004-05-09 09:32:26 +05:30
|
|
|
if family_id == child.get_main_parents_family_id():
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-02-14 11:10:30 +05:30
|
|
|
for family_type in child.get_parent_family_id_list():
|
2004-04-17 00:45:02 +05:30
|
|
|
if family_type[0] == family_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
break
|
|
|
|
else:
|
2004-04-17 00:45:02 +05:30
|
|
|
family.remove_child_id(child_id)
|
|
|
|
self.db.commit_family(family)
|
2004-05-09 09:32:26 +05:30
|
|
|
self.broken_links.append((child_id,family_id))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-05-21 23:36:41 +05:30
|
|
|
def cleanup_missing_photos(self,cl=0):
|
2004-01-18 07:29:30 +05:30
|
|
|
missmedia_action = 0
|
2003-05-14 08:16:59 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def remove_clicked():
|
|
|
|
# File is lost => remove all references and the object itself
|
2004-04-17 00:45:02 +05:30
|
|
|
for person_id in self.db.get_family_keys():
|
|
|
|
p = self.db.find_family_from_id(person_id)
|
2004-02-21 11:41:59 +05:30
|
|
|
nl = p.get_media_list()
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 0
|
2003-05-14 08:16:59 +05:30
|
|
|
for o in nl:
|
2004-02-25 08:55:57 +05:30
|
|
|
if o.get_reference_id() == ObjectId:
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 1
|
|
|
|
nl.remove(o)
|
|
|
|
if changed:
|
|
|
|
p.set_media_list(nl)
|
|
|
|
self.db.commit_person(p)
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for key in self.db.get_person_keys():
|
2004-04-17 00:45:02 +05:30
|
|
|
p = self.db.find_person_from_id(key)
|
2004-02-21 11:41:59 +05:30
|
|
|
nl = p.get_media_list()
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 0
|
2003-05-14 08:16:59 +05:30
|
|
|
for o in nl:
|
2004-02-25 08:55:57 +05:30
|
|
|
if o.get_reference_id() == ObjectId:
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 1
|
|
|
|
nl.remove(o)
|
|
|
|
if changed:
|
|
|
|
p.set_media_list(nl)
|
|
|
|
self.db.commit_person(p)
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for key in self.db.get_source_keys():
|
2004-04-17 00:45:02 +05:30
|
|
|
p = self.db.find_source_from_id(key)
|
2004-02-21 11:41:59 +05:30
|
|
|
nl = p.get_media_list()
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 0
|
2003-05-14 08:16:59 +05:30
|
|
|
for o in nl:
|
2004-02-25 08:55:57 +05:30
|
|
|
if o.get_reference_id() == ObjectId:
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 1
|
|
|
|
nl.remove(o)
|
|
|
|
if changed:
|
|
|
|
p.set_media_list(nl)
|
|
|
|
self.db.commit_source(p)
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
for key in self.db.get_place_id_keys():
|
|
|
|
p = self.db.get_place_id(key)
|
2004-02-21 11:41:59 +05:30
|
|
|
nl = p.get_media_list()
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 0
|
2003-05-14 08:16:59 +05:30
|
|
|
for o in nl:
|
2004-02-25 08:55:57 +05:30
|
|
|
if o.get_reference_id() == ObjectId:
|
2004-04-17 00:45:02 +05:30
|
|
|
changed = 1
|
|
|
|
nl.remove(o)
|
|
|
|
if changed:
|
|
|
|
p.set_media_list(nl)
|
|
|
|
self.db.commit_place(p)
|
2004-02-25 08:55:57 +05:30
|
|
|
self.removed_photo.append(ObjectId)
|
2004-02-14 11:10:30 +05:30
|
|
|
self.db.remove_object(ObjectId)
|
2003-05-14 08:16:59 +05:30
|
|
|
|
|
|
|
def leave_clicked():
|
2004-04-17 00:45:02 +05:30
|
|
|
self.bad_photo.append(ObjectId)
|
2003-05-14 08:16:59 +05:30
|
|
|
|
|
|
|
def select_clicked():
|
|
|
|
# File is lost => select a file to replace the lost one
|
|
|
|
def fs_close_window(obj):
|
2004-04-17 00:45:02 +05:30
|
|
|
self.bad_photo.append(ObjectId)
|
2003-05-14 08:16:59 +05:30
|
|
|
|
|
|
|
def fs_ok_clicked(obj):
|
|
|
|
name = fs_top.get_filename()
|
|
|
|
if os.path.isfile(name):
|
2003-06-04 02:48:23 +05:30
|
|
|
shutil.copyfile(name,photo_name)
|
|
|
|
try:
|
|
|
|
shutil.copystat(name,photo_name)
|
|
|
|
except:
|
|
|
|
pass
|
2004-04-17 00:45:02 +05:30
|
|
|
self.replaced_photo.append(ObjectId)
|
2003-05-14 08:16:59 +05:30
|
|
|
else:
|
2004-04-17 00:45:02 +05:30
|
|
|
self.bad_photo.append(ObjectId)
|
2003-05-14 08:16:59 +05:30
|
|
|
|
|
|
|
fs_top = gtk.FileSelection("%s - GRAMPS" % _("Select file"))
|
|
|
|
fs_top.hide_fileop_buttons()
|
|
|
|
fs_top.ok_button.connect('clicked',fs_ok_clicked)
|
|
|
|
fs_top.cancel_button.connect('clicked',fs_close_window)
|
|
|
|
fs_top.run()
|
2003-06-10 05:30:05 +05:30
|
|
|
fs_top.destroy()
|
2003-05-14 08:16:59 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
2004-04-17 00:45:02 +05:30
|
|
|
|
|
|
|
for ObjectId in self.db.get_object_keys():
|
|
|
|
obj = self.db.find_object_from_id(ObjectId)
|
|
|
|
photo_name = obj.get_path()
|
2003-05-14 08:16:59 +05:30
|
|
|
if not os.path.isfile(photo_name):
|
2003-05-21 23:36:41 +05:30
|
|
|
if cl:
|
|
|
|
print "Warning: media file %s was not found." \
|
|
|
|
% os.path.basename(photo_name)
|
2004-04-17 00:45:02 +05:30
|
|
|
self.bad_photo.append(ObjectId)
|
2003-05-21 23:36:41 +05:30
|
|
|
else:
|
2004-01-18 07:29:30 +05:30
|
|
|
if missmedia_action == 0:
|
|
|
|
mmd = MissingMediaDialog(_("Media object could not be found"),
|
2003-05-21 23:36:41 +05:30
|
|
|
_("%(file_name)s is referenced in the database, but no longer exists. "
|
|
|
|
"The file may have been deleted or moved to a different location. "
|
|
|
|
"You may choose to either remove the reference from the database, "
|
|
|
|
"keep the reference to the missing file, or select a new file."
|
|
|
|
) % { 'file_name' : photo_name },
|
2004-01-18 07:29:30 +05:30
|
|
|
remove_clicked, leave_clicked, select_clicked)
|
|
|
|
missmedia_action = mmd.default_action
|
|
|
|
elif missmedia_action == 1:
|
|
|
|
remove_clicked()
|
|
|
|
elif missmedia_action == 2:
|
|
|
|
leave_clicked()
|
|
|
|
elif missmedia_action == 3:
|
|
|
|
select_clicked()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def cleanup_empty_families(self,automatic):
|
2004-04-17 00:45:02 +05:30
|
|
|
for key in self.db.get_family_keys():
|
|
|
|
family = self.db.find_family_from_id(key)
|
2004-05-09 09:32:26 +05:30
|
|
|
if not family.get_father_id() and not family.get_mother_id():
|
|
|
|
self.empty_family.append(family_id)
|
|
|
|
self.delete_empty_family(family_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-09 09:32:26 +05:30
|
|
|
def delete_empty_family(self,family_id):
|
2004-02-14 11:10:30 +05:30
|
|
|
for key in self.db.get_person_keys():
|
2004-04-17 00:45:02 +05:30
|
|
|
child = self.db.find_person_from_id(key)
|
2004-05-09 09:32:26 +05:30
|
|
|
child.remove_parent_family_id(family_id)
|
|
|
|
child.remove_family_id(family_id)
|
|
|
|
self.db.delete_family(family_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def check_parent_relationships(self):
|
2004-04-17 00:45:02 +05:30
|
|
|
for key in self.db.get_family_keys():
|
|
|
|
family = self.db.find_family_from_id(key)
|
|
|
|
mother_id = family.get_mother_id()
|
|
|
|
father_id = family.get_father_id()
|
2004-05-09 09:32:26 +05:30
|
|
|
if father_id:
|
|
|
|
father = self.db.find_person_from_id(father_id)
|
|
|
|
if mother_id:
|
|
|
|
mother = self.db.find_person_from_id(mother_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
type = family.get_relationship()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-09 09:32:26 +05:30
|
|
|
if not father_id and not mother_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-05-09 09:32:26 +05:30
|
|
|
elif not father_id:
|
2004-02-14 11:10:30 +05:30
|
|
|
if mother.get_gender() == RelLib.Person.male:
|
2004-04-17 00:45:02 +05:30
|
|
|
family.set_father_id(mother_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
family.set_mother_id(None)
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_family(family)
|
2004-05-09 09:32:26 +05:30
|
|
|
elif not mother_id:
|
2004-02-14 11:10:30 +05:30
|
|
|
if father.get_gender() == RelLib.Person.female:
|
2004-04-17 00:45:02 +05:30
|
|
|
family.set_mother_id(father_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
family.set_father_id(None)
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_family(family)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
fgender = father.get_gender()
|
|
|
|
mgender = mother.get_gender()
|
2003-12-27 02:44:45 +05:30
|
|
|
if type != "Partners":
|
|
|
|
if fgender == mgender and fgender != RelLib.Person.unknown:
|
2004-02-14 11:10:30 +05:30
|
|
|
family.set_relationship("Partners")
|
2004-05-09 09:32:26 +05:30
|
|
|
self.fam_rel.append(family_id)
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_family(family)
|
2003-12-27 02:44:45 +05:30
|
|
|
elif fgender == RelLib.Person.female or mgender == RelLib.Person.male:
|
2004-04-17 00:45:02 +05:30
|
|
|
family.set_father_id(mother_id)
|
|
|
|
family.set_mother_id(father_id)
|
2004-05-09 09:32:26 +05:30
|
|
|
self.fam_rel.append(family_id)
|
2004-04-17 00:45:02 +05:30
|
|
|
self.db.commit_family(family)
|
2003-12-27 02:44:45 +05:30
|
|
|
elif fgender != mgender:
|
2004-02-14 11:10:30 +05:30
|
|
|
family.set_relationship("Unknown")
|
2004-05-09 09:32:26 +05:30
|
|
|
self.fam_rel.append(family_id)
|
2003-12-27 02:44:45 +05:30
|
|
|
if fgender == RelLib.Person.female or mgender == RelLib.Person.male:
|
2004-04-17 00:45:02 +05:30
|
|
|
family.set_father_id(mother_id)
|
|
|
|
family.set_mother_id(father_id)
|
|
|
|
self.db.commit_family(family)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-05-19 10:24:14 +05:30
|
|
|
def build_report(self,cl=0):
|
2003-05-14 08:16:59 +05:30
|
|
|
bad_photos = len(self.bad_photo)
|
|
|
|
replaced_photos = len(self.replaced_photo)
|
|
|
|
removed_photos = len(self.removed_photo)
|
|
|
|
photos = bad_photos + replaced_photos + removed_photos
|
2002-10-20 19:55:16 +05:30
|
|
|
efam = len(self.empty_family)
|
|
|
|
blink = len(self.broken_links)
|
|
|
|
plink = len(self.broken_parent_links)
|
|
|
|
rel = len(self.fam_rel)
|
2003-02-03 23:14:12 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
errors = blink + efam + photos + rel
|
|
|
|
|
|
|
|
if errors == 0:
|
2003-05-19 10:24:14 +05:30
|
|
|
if cl:
|
|
|
|
print "No errors were found: the database has passed internal checks."
|
|
|
|
else:
|
|
|
|
OkDialog(_("No errors were found"),
|
|
|
|
_('The database has passed internal checks'))
|
|
|
|
return 0
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text = cStringIO.StringIO()
|
2002-10-20 19:55:16 +05:30
|
|
|
if blink > 0:
|
|
|
|
if blink == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("1 broken child/family link was fixed\n"))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("%d broken child/family links were found\n") % blink)
|
2004-05-09 09:32:26 +05:30
|
|
|
for (person_id,family_id) in self.broken_links:
|
|
|
|
person = self.db.find_person_from_id(person_id)
|
|
|
|
family = self.db.find_family_from_id(family_id)
|
|
|
|
cn = person.get_primary_name().get_name()
|
|
|
|
f = self.db.find_person_from_id(family.get_father_id())
|
|
|
|
m = self.db.find_person_from_id(family.get_mother_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
if f and m:
|
2004-02-14 11:10:30 +05:30
|
|
|
pn = _("%s and %s") % (f.get_primary_name().get_name(),\
|
|
|
|
m.get_primary_name().get_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
elif f:
|
2004-02-14 11:10:30 +05:30
|
|
|
pn = f.get_primary_name().get_name()
|
2003-06-02 18:53:54 +05:30
|
|
|
elif m:
|
2004-02-14 11:10:30 +05:30
|
|
|
pn = m.get_primary_name().get_name()
|
2003-06-02 18:53:54 +05:30
|
|
|
else:
|
|
|
|
pn = _("unknown")
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write('\t')
|
2003-06-02 18:53:54 +05:30
|
|
|
self.text.write(_("%s was removed from the family of %s\n") % (cn,pn))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if plink > 0:
|
|
|
|
if plink == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("1 broken spouse/family link was fixed\n"))
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("%d broken spouse/family links were found\n") % plink)
|
2004-05-09 09:32:26 +05:30
|
|
|
for (person_id,family_id) in self.broken_parent_links:
|
|
|
|
person = self.db.find_person_from_id(person_id)
|
|
|
|
family = self.db.find_family_from_id(family_id)
|
|
|
|
cn = person.get_primary_name().get_name()
|
|
|
|
f = self.db.find_person_from_id(family.get_father_id())
|
|
|
|
m = self.db.find_person_from_id(family.get_mother_id())
|
2002-10-20 19:55:16 +05:30
|
|
|
if f and m:
|
2004-02-14 11:10:30 +05:30
|
|
|
pn = _("%s and %s") % (f.get_primary_name().get_name(),\
|
|
|
|
m.get_primary_name().get_name())
|
2002-10-20 19:55:16 +05:30
|
|
|
elif f:
|
2004-02-14 11:10:30 +05:30
|
|
|
pn = f.get_primary_name().get_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-02-14 11:10:30 +05:30
|
|
|
pn = m.get_primary_name().get_name()
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write('\t')
|
|
|
|
self.text.write(_("%s was restored to the family of %s\n") % (cn,pn))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if efam == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("1 empty family was found\n"))
|
2002-10-20 19:55:16 +05:30
|
|
|
elif efam > 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("%d empty families were found\n") % efam)
|
2002-10-20 19:55:16 +05:30
|
|
|
if rel == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("1 corrupted family relationship fixed\n"))
|
2002-10-20 19:55:16 +05:30
|
|
|
elif rel > 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("%d corrupted family relationship fixed\n") % rel)
|
2002-10-20 19:55:16 +05:30
|
|
|
if photos == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("1 media object was referenced, but not found\n"))
|
2002-10-20 19:55:16 +05:30
|
|
|
elif photos > 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("%d media objects were referenced, but not found\n") % photos)
|
2003-05-14 08:16:59 +05:30
|
|
|
if bad_photos == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("Reference to 1 missing media object was kept\n"))
|
2003-05-14 08:16:59 +05:30
|
|
|
elif bad_photos > 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("References to %d media objects were kept\n") % bad_photos)
|
2003-05-14 08:16:59 +05:30
|
|
|
if replaced_photos == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("1 missing media object was replaced\n"))
|
2003-05-14 08:16:59 +05:30
|
|
|
elif replaced_photos > 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("%d missing media objects were replaced\n") % replaced_photos)
|
2003-05-14 08:16:59 +05:30
|
|
|
if removed_photos == 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("1 missing media object was removed\n"))
|
2003-05-14 08:16:59 +05:30
|
|
|
elif removed_photos > 1:
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.write(_("%d missing media objects were removed\n") % removed_photos)
|
|
|
|
|
|
|
|
return errors
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2003-05-19 10:24:14 +05:30
|
|
|
def report(self,cl=0):
|
2004-05-09 09:32:26 +05:30
|
|
|
if cl:
|
2003-05-19 10:24:14 +05:30
|
|
|
print self.text.getvalue()
|
2004-05-09 09:32:26 +05:30
|
|
|
else:
|
2003-05-19 10:24:14 +05:30
|
|
|
base = os.path.dirname(__file__)
|
|
|
|
glade_file = base + os.sep + "summary.glade"
|
2003-08-17 07:44:33 +05:30
|
|
|
topDialog = gtk.glade.XML(glade_file,"summary","gramps")
|
2003-05-19 10:24:14 +05:30
|
|
|
topDialog.signal_autoconnect({
|
|
|
|
"destroy_passed_object" : Utils.destroy_passed_object,
|
|
|
|
})
|
|
|
|
title = _("Check Integrity")
|
|
|
|
top = topDialog.get_widget("summary")
|
|
|
|
textwindow = topDialog.get_widget("textwindow")
|
2003-03-23 01:56:44 +05:30
|
|
|
|
2003-05-19 10:24:14 +05:30
|
|
|
Utils.set_titles(top,topDialog.get_widget("title"),title)
|
2004-05-09 09:32:26 +05:30
|
|
|
textwindow.get_buffer().set_text(self.text.getvalue())
|
2003-05-19 10:24:14 +05:30
|
|
|
self.text.close()
|
|
|
|
top.show()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
from Plugins import register_tool
|
|
|
|
|
|
|
|
register_tool(
|
|
|
|
runTool,
|
|
|
|
_("Check and repair database"),
|
|
|
|
category=_("Database Processing"),
|
|
|
|
description=_("Checks the database for integrity problems, fixing the problems that it can")
|
|
|
|
)
|