2005-08-18 11:28:28 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
2006-03-01 01:24:35 +05:30
|
|
|
# Copyright (C) 2000-2006 Donald N. Allingham
|
2005-08-18 11:28:28 +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
|
|
|
|
#
|
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
"Database Processing/Check and repair database"
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# python modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import os
|
|
|
|
import cStringIO
|
|
|
|
from gettext import gettext as _
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# gtk modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# GRAMPS modules
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
import RelLib
|
|
|
|
import Utils
|
|
|
|
import const
|
2005-12-06 12:08:09 +05:30
|
|
|
import Tool
|
2005-08-18 11:28:28 +05:30
|
|
|
from QuestionDialog import OkDialog
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# runTool
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
class Rebuild(Tool.Tool):
|
|
|
|
def __init__(self,db,person,options_class,name,callback=None,parent=None):
|
|
|
|
Tool.Tool.__init__(self,db,person,options_class,name)
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
try:
|
|
|
|
if db.readonly:
|
|
|
|
# TODO: split plugin in a check and repair part to support
|
|
|
|
# checking of a read only database
|
|
|
|
return
|
2005-08-18 11:28:28 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
db.disable_signals()
|
|
|
|
if parent:
|
|
|
|
progress = Utils.ProgressMeter(
|
|
|
|
_('Rebuilding Secondary Indices'))
|
2006-03-01 01:24:35 +05:30
|
|
|
# Six indices to rebuild, and the first step is removing
|
|
|
|
# old ones
|
|
|
|
total = 7
|
2005-12-06 12:08:09 +05:30
|
|
|
progress.set_pass('',total)
|
|
|
|
db.rebuild_secondary(progress.step)
|
|
|
|
progress.close()
|
|
|
|
OkDialog(_("Secondary indices rebuilt"),
|
|
|
|
_('All secondary indices have been rebuilt.'))
|
|
|
|
else:
|
|
|
|
print "Rebuilding Secondary Indices..."
|
|
|
|
db.rebuild_secondary(self.empty)
|
|
|
|
print "All secondary indices have been rebuilt."
|
|
|
|
db.enable_signals()
|
|
|
|
except:
|
|
|
|
import DisplayTrace
|
|
|
|
DisplayTrace.DisplayTrace()
|
|
|
|
|
|
|
|
def empty(self):
|
|
|
|
pass
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
class RebuildOptions(Tool.ToolOptions):
|
|
|
|
"""
|
|
|
|
Defines options and provides handling interface.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def __init__(self,name,person_id=None):
|
|
|
|
Tool.ToolOptions.__init__(self,name,person_id)
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-08-18 11:28:28 +05:30
|
|
|
from PluginMgr import register_tool
|
|
|
|
|
|
|
|
register_tool(
|
2005-12-06 12:08:09 +05:30
|
|
|
name = 'rebuild',
|
|
|
|
category = Tool.TOOL_DBFIX,
|
|
|
|
tool_class = Rebuild,
|
|
|
|
options_class = RebuildOptions,
|
|
|
|
modes = Tool.MODE_GUI | Tool.MODE_CLI,
|
|
|
|
translated_name = _("Rebuild secondary indices"),
|
|
|
|
status=(_("Stable")),
|
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "don@gramps-project.org",
|
2005-08-18 11:28:28 +05:30
|
|
|
description=_("Rebuilds secondary indices")
|
|
|
|
)
|