* src/plugins/PatchNames.py: Convert to new API.
* src/plugins/RelCalc.py: Convert to new API. * src/plugins/ReorderIds.py: Convert to new API. * src/plugins/SoundGen.py: Convert to new API. * src/plugins/Rebuild.py: Convert to new API. svn: r5270
This commit is contained in:
parent
278b7751ba
commit
561716a398
@ -1,3 +1,10 @@
|
||||
2005-10-04 Alex Roitman <shura@gramps-project.org>
|
||||
* src/plugins/PatchNames.py: Convert to new API.
|
||||
* src/plugins/RelCalc.py: Convert to new API.
|
||||
* src/plugins/ReorderIds.py: Convert to new API.
|
||||
* src/plugins/SoundGen.py: Convert to new API.
|
||||
* src/plugins/Rebuild.py: Convert to new API.
|
||||
|
||||
2005-10-04 Don Allingham <don@gramps-project.org>
|
||||
* src/DateParser.py: handle non-matching dates as strings properly
|
||||
|
||||
|
@ -47,6 +47,7 @@ from gnome import help_display
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Utils
|
||||
import Tool
|
||||
from QuestionDialog import OkDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -75,21 +76,16 @@ _sn_prefix_re = re.compile("^\s*(%s)\s+(.*)" % '|'.join(prefix_list),re.IGNORECA
|
||||
# to "Name" and add "Nickname" into the nickname field.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback,parent=None):
|
||||
try:
|
||||
PatchNames(database,callback,parent)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# PatchNames
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class PatchNames:
|
||||
class PatchNames(Tool.Tool):
|
||||
def __init__(self,db,person,options_class,name,callback=None,parent=None):
|
||||
Tool.Tool.__init__(self,db,person,options_class,name)
|
||||
|
||||
def __init__(self,db,callback,parent):
|
||||
self.cb = callback
|
||||
self.db = db
|
||||
self.parent = parent
|
||||
@ -336,12 +332,30 @@ class PatchNames:
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class PatchNamesOptions(Tool.ToolOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
Tool.ToolOptions.__init__(self,name,person_id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from PluginMgr import register_tool
|
||||
|
||||
register_tool(
|
||||
runTool,
|
||||
_("Extract information from names"),
|
||||
category=_("Database Processing"),
|
||||
name = 'patchnames',
|
||||
category = Tool.TOOL_DBPROC,
|
||||
tool_class = PatchNames,
|
||||
options_class = PatchNamesOptions,
|
||||
modes = Tool.MODE_GUI,
|
||||
translated_name = _("Extract information from names"),
|
||||
author_name = "Donald N. Allingham",
|
||||
author_email = "dallingham@users.sourceforge.net",
|
||||
description=_("Searches the entire database and attempts to "
|
||||
"extract titles, nicknames and surname prefixes "
|
||||
"that may be embedded in a person's given name field.")
|
||||
|
@ -47,6 +47,7 @@ import gtk.glade
|
||||
import RelLib
|
||||
import Utils
|
||||
import const
|
||||
import Tool
|
||||
from QuestionDialog import OkDialog
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -54,40 +55,71 @@ from QuestionDialog import OkDialog
|
||||
# runTool
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback,parent=None):
|
||||
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)
|
||||
|
||||
try:
|
||||
if database.readonly:
|
||||
# TODO: split plugin in a check and repair part to support
|
||||
# checking of a read only database
|
||||
return
|
||||
try:
|
||||
if db.readonly:
|
||||
# TODO: split plugin in a check and repair part to support
|
||||
# checking of a read only database
|
||||
return
|
||||
|
||||
total = database.get_number_of_people() + database.get_number_of_families() + \
|
||||
database.get_number_of_places() + database.get_number_of_sources() + \
|
||||
database.get_number_of_media_objects()
|
||||
total = db.get_number_of_people() + \
|
||||
db.get_number_of_families() + \
|
||||
db.get_number_of_places() + \
|
||||
db.get_number_of_sources() + \
|
||||
db.get_number_of_media_objects()
|
||||
|
||||
progress = Utils.ProgressMeter(_('Rebuilding Secondary Indices'))
|
||||
progress.set_pass('',total)
|
||||
database.disable_signals()
|
||||
database.rebuild_secondary(progress.step)
|
||||
database.enable_signals()
|
||||
progress.close()
|
||||
OkDialog(_("Secondary indices rebuilt"),
|
||||
_('All secondary indices have been rebuilt.'))
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
db.disable_signals()
|
||||
if parent:
|
||||
progress = Utils.ProgressMeter(
|
||||
_('Rebuilding Secondary Indices'))
|
||||
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
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class RebuildOptions(Tool.ToolOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
Tool.ToolOptions.__init__(self,name,person_id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from PluginMgr import register_tool
|
||||
|
||||
register_tool(
|
||||
runTool,
|
||||
_("Rebuild secondary indices"),
|
||||
category=_("Database Repair"),
|
||||
name = 'rebuild',
|
||||
category = Tool.TOOL_DBFIX,
|
||||
tool_class = Rebuild,
|
||||
options_class = RebuildOptions,
|
||||
modes = Tool.MODE_GUI | Tool.MODE_CLI,
|
||||
translated_name = _("Rebuild secondary indices"),
|
||||
author_name = "Donald N. Allingham",
|
||||
author_email = "dallingham@users.sourceforge.net",
|
||||
description=_("Rebuilds secondary indices")
|
||||
)
|
||||
|
@ -48,6 +48,7 @@ import NameDisplay
|
||||
import ListModel
|
||||
import PluginMgr
|
||||
import PeopleModel
|
||||
import Tool
|
||||
|
||||
column_names = [
|
||||
_('Name'),
|
||||
@ -67,24 +68,17 @@ column_names = [
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,person,callback,parent=None):
|
||||
RelCalc(database,person,parent)
|
||||
class RelCalc(Tool.Tool):
|
||||
def __init__(self,db,person,options_class,name,callback=None,parent=None):
|
||||
Tool.Tool.__init__(self,db,person,options_class,name)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RelCalc:
|
||||
"""
|
||||
Relationship calculator class.
|
||||
"""
|
||||
"""
|
||||
Relationship calculator class.
|
||||
"""
|
||||
|
||||
def __init__(self,database,person,parent):
|
||||
self.person = person
|
||||
self.db = database
|
||||
self.RelClass = PluginMgr.relationship_class
|
||||
self.relationship = self.RelClass(database)
|
||||
self.relationship = self.RelClass(self.db)
|
||||
self.parent = parent
|
||||
self.win_key = self
|
||||
|
||||
@ -216,15 +210,32 @@ class RelCalc:
|
||||
|
||||
text1.set_text("%s %s" % (rstr, commontext))
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
#------------------------------------------------------------------------
|
||||
class RelCalcOptions(Tool.ToolOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
Tool.ToolOptions.__init__(self,name,person_id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
PluginMgr.register_tool(
|
||||
runTool,
|
||||
_("Relationship calculator"),
|
||||
category=_("Utilities"),
|
||||
name = 'relcalc',
|
||||
category = Tool.TOOL_UTILS,
|
||||
tool_class = RelCalc,
|
||||
options_class = RelCalcOptions,
|
||||
modes = Tool.MODE_GUI,
|
||||
translated_name = _("Relationship calculator"),
|
||||
author_name = "Donald N. Allingham",
|
||||
author_email = "dallingham@users.sourceforge.net",
|
||||
description=_("Calculates the relationship between two people")
|
||||
)
|
||||
|
@ -40,64 +40,88 @@ from gettext import gettext as _
|
||||
#------------------------------------------------------------------------
|
||||
import Utils
|
||||
import RelLib
|
||||
import Tool
|
||||
from QuestionDialog import WarningDialog
|
||||
|
||||
_findint = re.compile('^[^\d]*(\d+)[^\d]*')
|
||||
|
||||
def runTool(db,active_person,callback,parent):
|
||||
"""Changed person, family, object, source, and place ids"""
|
||||
#FIXME -- Remove when the tool is back from the dead
|
||||
#WarningDialog(_('Tool currently unavailable'),
|
||||
# _('This tool has not yet been brought up to date '
|
||||
# 'after transition to the database, sorry.'),parent.topWindow)
|
||||
#return
|
||||
|
||||
#FIXME
|
||||
try:
|
||||
ReorderIds(db)
|
||||
except:
|
||||
import DisplayTrace
|
||||
DisplayTrace.DisplayTrace()
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Actual tool
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ReorderIds:
|
||||
class ReorderIds(Tool.Tool):
|
||||
def __init__(self,db,person,options_class,name,callback=None,parent=None):
|
||||
Tool.Tool.__init__(self,db,person,options_class,name)
|
||||
|
||||
def __init__(self,db):
|
||||
|
||||
self.db = db
|
||||
|
||||
self.progress = Utils.ProgressMeter(_('Reordering GRAMPS IDs'),'')
|
||||
self.parent = parent
|
||||
if parent:
|
||||
self.progress = Utils.ProgressMeter(_('Reordering GRAMPS IDs'),'')
|
||||
else:
|
||||
print "Reordering GRAMPS IDs..."
|
||||
|
||||
self.trans = db.transaction_begin()
|
||||
|
||||
self.progress.set_pass(_('Reordering People IDs'),db.get_number_of_people())
|
||||
self.reorder(RelLib.Person, db.get_person_from_gramps_id, db.get_person_from_handle,
|
||||
db.find_next_person_gramps_id, db.get_person_cursor, db.commit_person,
|
||||
if parent:
|
||||
self.progress.set_pass(_('Reordering People IDs'),
|
||||
db.get_number_of_people())
|
||||
self.reorder(RelLib.Person,
|
||||
db.get_person_from_gramps_id,
|
||||
db.get_person_from_handle,
|
||||
db.find_next_person_gramps_id,
|
||||
db.get_person_cursor,
|
||||
db.commit_person,
|
||||
db.iprefix)
|
||||
self.progress.set_pass(_('Reordering Family IDs'),db.get_number_of_families())
|
||||
self.reorder(RelLib.Family,db.get_family_from_gramps_id, db.get_family_from_handle,
|
||||
db.find_next_family_gramps_id, db.get_family_cursor, db.commit_family,
|
||||
|
||||
if parent:
|
||||
self.progress.set_pass(_('Reordering Family IDs'),
|
||||
db.get_number_of_families())
|
||||
self.reorder(RelLib.Family,
|
||||
db.get_family_from_gramps_id,
|
||||
db.get_family_from_handle,
|
||||
db.find_next_family_gramps_id,
|
||||
db.get_family_cursor,
|
||||
db.commit_family,
|
||||
db.fprefix)
|
||||
self.progress.set_pass(_('Reordering Media Object IDs'),db.get_number_of_media_objects())
|
||||
self.reorder(RelLib.MediaObject, db.get_object_from_gramps_id, db.get_object_from_handle,
|
||||
db.find_next_object_gramps_id, db.get_media_cursor, db.commit_media_object,
|
||||
if parent:
|
||||
self.progress.set_pass(_('Reordering Media Object IDs'),
|
||||
db.get_number_of_media_objects())
|
||||
self.reorder(RelLib.MediaObject,
|
||||
db.get_object_from_gramps_id,
|
||||
db.get_object_from_handle,
|
||||
db.find_next_object_gramps_id,
|
||||
db.get_media_cursor,
|
||||
db.commit_media_object,
|
||||
db.oprefix)
|
||||
self.progress.set_pass(_('Reordering Source IDs'),db.get_number_of_sources())
|
||||
self.reorder(RelLib.Source, db.get_source_from_gramps_id, db.get_source_from_handle,
|
||||
db.find_next_source_gramps_id, db.get_source_cursor, db.commit_source,
|
||||
if parent:
|
||||
self.progress.set_pass(_('Reordering Source IDs'),
|
||||
db.get_number_of_sources())
|
||||
self.reorder(RelLib.Source,
|
||||
db.get_source_from_gramps_id,
|
||||
db.get_source_from_handle,
|
||||
db.find_next_source_gramps_id,
|
||||
db.get_source_cursor,
|
||||
db.commit_source,
|
||||
db.sprefix)
|
||||
self.progress.set_pass(_('Reordering Place IDs'),db.get_number_of_places())
|
||||
self.reorder(RelLib.Place, db.get_place_from_gramps_id, db.get_place_from_handle,
|
||||
db.find_next_place_gramps_id, db.get_place_cursor, db.commit_place,
|
||||
if parent:
|
||||
self.progress.set_pass(_('Reordering Place IDs'),
|
||||
db.get_number_of_places())
|
||||
self.reorder(RelLib.Place,
|
||||
db.get_place_from_gramps_id,
|
||||
db.get_place_from_handle,
|
||||
db.find_next_place_gramps_id,
|
||||
db.get_place_cursor,
|
||||
db.commit_place,
|
||||
db.pprefix)
|
||||
self.progress.close()
|
||||
if parent:
|
||||
self.progress.close()
|
||||
else:
|
||||
print "Done."
|
||||
|
||||
db.transaction_commit(self.trans,_("Reorder GRAMPS IDs"))
|
||||
|
||||
def reorder(self, class_type, find_from_id, find_from_handle, find_next_id, get_cursor, commit, prefix):
|
||||
def reorder(self, class_type, find_from_id, find_from_handle,
|
||||
find_next_id, get_cursor, commit, prefix):
|
||||
dups = []
|
||||
newids = {}
|
||||
key_list = []
|
||||
@ -107,7 +131,8 @@ class ReorderIds:
|
||||
cursor = get_cursor()
|
||||
data = cursor.first()
|
||||
while data:
|
||||
self.progress.step()
|
||||
if self.parent:
|
||||
self.progress.step()
|
||||
(handle,sdata) = data
|
||||
|
||||
obj = class_type()
|
||||
@ -144,13 +169,29 @@ class ReorderIds:
|
||||
# go through the duplicates, looking for the first availble
|
||||
# handle that matches the new scheme.
|
||||
|
||||
self.progress.set_pass(_('Finding and assigning unused IDs'),len(dups))
|
||||
if self.parent:
|
||||
self.progress.set_pass(_('Finding and assigning unused IDs'),
|
||||
len(dups))
|
||||
for handle in dups:
|
||||
self.progress.step()
|
||||
if self.parent:
|
||||
self.progress.step()
|
||||
obj = find_from_handle(handle)
|
||||
obj.set_gramps_id(find_next_id())
|
||||
commit(obj,self.trans)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class ReorderIdsOptions(Tool.ToolOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
Tool.ToolOptions.__init__(self,name,person_id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -159,8 +200,14 @@ class ReorderIds:
|
||||
from PluginMgr import register_tool
|
||||
|
||||
register_tool(
|
||||
runTool,
|
||||
_("Reorder GRAMPS IDs"),
|
||||
category=_("Database Processing"),
|
||||
description=_("Reorders the gramps IDs according to gramps' default rules.")
|
||||
name = 'reorder_ids',
|
||||
category = Tool.TOOL_DBPROC,
|
||||
tool_class = ReorderIds,
|
||||
options_class = ReorderIdsOptions,
|
||||
modes = Tool.MODE_GUI | Tool.MODE_CLI,
|
||||
translated_name = _("Reorder GRAMPS IDs"),
|
||||
author_name = "Donald N. Allingham",
|
||||
author_email = "dallingham@users.sourceforge.net",
|
||||
description=_("Reorders the gramps IDs "
|
||||
"according to gramps' default rules.")
|
||||
)
|
||||
|
@ -47,21 +47,16 @@ from gnome import help_display
|
||||
import soundex
|
||||
import Utils
|
||||
import AutoComp
|
||||
import Tool
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
def runTool(database,active_person,callback,parent=None):
|
||||
SoundGen(database,active_person,parent)
|
||||
class SoundGen(Tool.Tool):
|
||||
def __init__(self,db,person,options_class,name,callback=None,parent=None):
|
||||
Tool.Tool.__init__(self,db,person,options_class,name)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SoundGen:
|
||||
def __init__(self,database,active_person,parent):
|
||||
self.db = database
|
||||
self.parent = parent
|
||||
if self.parent.child_windows.has_key(self.__class__):
|
||||
self.parent.child_windows[self.__class__].present(None)
|
||||
@ -101,8 +96,8 @@ class SoundGen:
|
||||
|
||||
AutoComp.fill_combo(self.autocomp, names)
|
||||
|
||||
if active_person:
|
||||
n = active_person.get_primary_name().get_surname()
|
||||
if person:
|
||||
n = person.get_primary_name().get_surname()
|
||||
self.name.set_text(n)
|
||||
try:
|
||||
se_text = soundex.soundex(n)
|
||||
@ -147,6 +142,19 @@ class SoundGen:
|
||||
se_text = soundex.soundex('')
|
||||
self.value.set_text(se_text)
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
class SoundGenOptions(Tool.ToolOptions):
|
||||
"""
|
||||
Defines options and provides handling interface.
|
||||
"""
|
||||
|
||||
def __init__(self,name,person_id=None):
|
||||
Tool.ToolOptions.__init__(self,name,person_id)
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -155,8 +163,13 @@ class SoundGen:
|
||||
from PluginMgr import register_tool
|
||||
|
||||
register_tool(
|
||||
runTool,
|
||||
_("Generate SoundEx codes"),
|
||||
category=_("Utilities"),
|
||||
name = 'soundgen',
|
||||
category = Tool.TOOL_UTILS,
|
||||
tool_class = SoundGen,
|
||||
options_class = SoundGenOptions,
|
||||
modes = Tool.MODE_GUI,
|
||||
translated_name = _("Generate SoundEx codes"),
|
||||
author_name = "Donald N. Allingham",
|
||||
author_email = "dallingham@users.sourceforge.net",
|
||||
description=_("Generates SoundEx codes for names")
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user