* src/plugins/Check.py: Convert to new API.

svn: r5262
This commit is contained in:
Alex Roitman 2005-10-02 02:04:36 +00:00
parent 66922b94cc
commit 2eef51be37
2 changed files with 61 additions and 36 deletions

View File

@ -2,6 +2,7 @@
* src/plugins/Verify.py: Convert to new API.
* src/plugins/verify.glade: Use separate windows for errors and
warnings.
* src/plugins/Check.py: Convert to new API.
2005-09-30 Alex Roitman <shura@gramps-project.org>
* src/docgen/KwordDoc.py: Remove unused latin_utf8 import.

View File

@ -48,6 +48,7 @@ import gtk.glade
import RelLib
import Utils
import const
import Tool
from QuestionDialog import OkDialog, MissingMediaDialog
#-------------------------------------------------------------------------
@ -55,46 +56,51 @@ from QuestionDialog import OkDialog, MissingMediaDialog
# runTool
#
#-------------------------------------------------------------------------
def runTool(database,active_person,callback,parent=None):
class Check(Tool.Tool):
def __init__(self,db,person,options_class,name,callback=None,parent=None):
Tool.Tool.__init__(self,db,person,options_class,name)
try:
if database.readonly:
# TODO: split plugin in a check and repair part to support
# checking of a read only database
return
trans = database.transaction_begin()
trans.set_batch(True)
database.disable_signals()
checker = CheckIntegrity(database,parent,trans)
checker.cleanup_missing_photos(0)
# def runTool(database,active_person,callback,parent=None):
cli = int(parent == None)
prev_total = -1
total = 0
try:
if db.readonly:
# TODO: split plugin in a check and repair part to support
# checking of a read only database
return
while prev_total != total:
prev_total = total
trans = db.transaction_begin()
trans.set_batch(True)
db.disable_signals()
checker = CheckIntegrity(db,parent,trans)
checker.cleanup_missing_photos(cli)
prev_total = -1
total = 0
while prev_total != total:
prev_total = total
checker.check_for_broken_family_links()
checker.check_parent_relationships()
checker.cleanup_empty_families(0)
checker.cleanup_duplicate_spouses()
checker.check_for_broken_family_links()
checker.check_parent_relationships()
checker.cleanup_empty_families(cli)
checker.cleanup_duplicate_spouses()
total = checker.family_errors()
total = checker.family_errors()
checker.check_events()
checker.check_place_references()
checker.check_source_references()
database.transaction_commit(trans, _("Check Integrity"))
database.enable_signals()
database.request_rebuild()
checker.check_events()
checker.check_place_references()
checker.check_source_references()
db.transaction_commit(trans, _("Check Integrity"))
db.enable_signals()
db.request_rebuild()
errs = checker.build_report(0)
if errs:
Report(checker.text.getvalue(),parent)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
errs = checker.build_report(cli)
if errs:
Report(checker.text.getvalue(),parent)
except:
import DisplayTrace
DisplayTrace.DisplayTrace()
#-------------------------------------------------------------------------
#
@ -843,6 +849,19 @@ class Report:
def present_result(self,obj):
self.window.present()
#------------------------------------------------------------------------
#
#
#
#------------------------------------------------------------------------
class CheckOptions(Tool.ToolOptions):
"""
Defines options and provides handling interface.
"""
def __init__(self,name,person_id=None):
Tool.ToolOptions.__init__(self,name,person_id)
#------------------------------------------------------------------------
#
#
@ -851,8 +870,13 @@ class Report:
from PluginMgr import register_tool
register_tool(
runTool,
_("Check and repair database"),
category=_("Database Repair"),
name = 'check',
category = Tool.TOOL_DBFIX,
tool_class = Check,
options_class = CheckOptions,
modes = Tool.MODE_GUI | Tool.MODE_CLI,
translated_name = _("Check and repair database"),
author_name = "Donald N. Allingham",
author_email = "dallingham@users.sourceforge.net",
description=_("Checks the database for integrity problems, fixing the problems that it can")
)