* src/plugins/EventCmp.py: Convert to new API.
* src/plugins/Merge.py: Convert to new API. svn: r5267
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
2005-10-03 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/plugins/EventCmp.py: Convert to new API.
|
||||||
|
* src/plugins/Merge.py: Convert to new API.
|
||||||
|
|
||||||
2005-10-03 Don Allingham <don@gramps-project.org>
|
2005-10-03 Don Allingham <don@gramps-project.org>
|
||||||
* src/Utils.py: grab the first word of a command line string
|
* src/Utils.py: grab the first word of a command line string
|
||||||
* src/plugins/DetAncestralReport.py: work on spouse information
|
* src/plugins/DetAncestralReport.py: work on spouse information
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ import BaseDoc
|
|||||||
import OpenSpreadSheet
|
import OpenSpreadSheet
|
||||||
import const
|
import const
|
||||||
from QuestionDialog import WarningDialog
|
from QuestionDialog import WarningDialog
|
||||||
|
import Tool
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -122,10 +123,10 @@ class TableReport:
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
class EventComparison:
|
class EventComparison(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,database,parent):
|
|
||||||
self.db = database
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
if self.parent.child_windows.has_key(self.__class__):
|
if self.parent.child_windows.has_key(self.__class__):
|
||||||
self.parent.child_windows[self.__class__].present(None)
|
self.parent.child_windows[self.__class__].present(None)
|
||||||
@@ -140,7 +141,7 @@ class EventComparison:
|
|||||||
self.filterDialog.signal_autoconnect({
|
self.filterDialog.signal_autoconnect({
|
||||||
"on_apply_clicked" : self.on_apply_clicked,
|
"on_apply_clicked" : self.on_apply_clicked,
|
||||||
"on_editor_clicked" : self.filter_editor_clicked,
|
"on_editor_clicked" : self.filter_editor_clicked,
|
||||||
"on_filter_list_enter" : self.filter_list_enter,
|
## "on_filter_list_enter" : self.filter_list_enter,
|
||||||
"on_filters_delete_event": self.on_delete_event,
|
"on_filters_delete_event": self.on_delete_event,
|
||||||
"on_help_clicked" : self.on_help_clicked,
|
"on_help_clicked" : self.on_help_clicked,
|
||||||
"destroy_passed_object" : self.close
|
"destroy_passed_object" : self.close
|
||||||
@@ -159,6 +160,9 @@ class EventComparison:
|
|||||||
self.all.add_rule(GenericFilter.Everyone([]))
|
self.all.add_rule(GenericFilter.Everyone([]))
|
||||||
|
|
||||||
self.filter_menu = GenericFilter.build_filter_menu([self.all])
|
self.filter_menu = GenericFilter.build_filter_menu([self.all])
|
||||||
|
filter_num = self.options.handler.get_filter_number()
|
||||||
|
self.filter_menu.set_active(filter_num)
|
||||||
|
self.filter_menu.show()
|
||||||
self.filters.set_menu(self.filter_menu)
|
self.filters.set_menu(self.filter_menu)
|
||||||
|
|
||||||
self.add_itself_to_menu()
|
self.add_itself_to_menu()
|
||||||
@@ -193,9 +197,9 @@ class EventComparison:
|
|||||||
import FilterEditor
|
import FilterEditor
|
||||||
FilterEditor.FilterEditor(const.custom_filters,self.db,self.parent)
|
FilterEditor.FilterEditor(const.custom_filters,self.db,self.parent)
|
||||||
|
|
||||||
def filter_list_enter(self,obj):
|
## def filter_list_enter(self,obj):
|
||||||
self.filter_menu = GenericFilter.build_filter_menu([self.all])
|
## self.filter_menu = GenericFilter.build_filter_menu([self.all])
|
||||||
self.filters.set_menu(self.filter_menu)
|
## self.filters.set_menu(self.filter_menu)
|
||||||
|
|
||||||
def on_apply_clicked(self,obj):
|
def on_apply_clicked(self,obj):
|
||||||
cfilter = self.filter_menu.get_active().get_data("filter")
|
cfilter = self.filter_menu.get_active().get_data("filter")
|
||||||
@@ -207,20 +211,15 @@ class EventComparison:
|
|||||||
self.db.get_person_handles(sort_handles=False))
|
self.db.get_person_handles(sort_handles=False))
|
||||||
progress_bar.step()
|
progress_bar.step()
|
||||||
progress_bar.close()
|
progress_bar.close()
|
||||||
|
self.options.handler.set_filter_number(self.filters.get_history())
|
||||||
|
# Save options
|
||||||
|
self.options.handler.save_options()
|
||||||
|
|
||||||
if len(plist) == 0:
|
if len(plist) == 0:
|
||||||
WarningDialog(_("No matches were found"))
|
WarningDialog(_("No matches were found"))
|
||||||
else:
|
else:
|
||||||
DisplayChart(self.db,plist,self.parent)
|
DisplayChart(self.db,plist,self.parent)
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#------------------------------------------------------------------------
|
|
||||||
def runTool(database,person,callback,parent=None):
|
|
||||||
EventComparison(database,parent)
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -450,6 +449,25 @@ class DisplayChart:
|
|||||||
spreadsheet.finalize()
|
spreadsheet.finalize()
|
||||||
Utils.destroy_passed_object(obj)
|
Utils.destroy_passed_object(obj)
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
class EventComparisonOptions(Tool.ToolOptions):
|
||||||
|
"""
|
||||||
|
Defines options and provides handling interface.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self,name,person_id=None):
|
||||||
|
Tool.ToolOptions.__init__(self,name,person_id)
|
||||||
|
|
||||||
|
def enable_options(self):
|
||||||
|
# Semi-common options that should be enabled for this report
|
||||||
|
self.enable_dict = {
|
||||||
|
'filter' : 0,
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -458,9 +476,14 @@ class DisplayChart:
|
|||||||
from PluginMgr import register_tool
|
from PluginMgr import register_tool
|
||||||
|
|
||||||
register_tool(
|
register_tool(
|
||||||
runTool,
|
name = 'eventcmp',
|
||||||
_("Compare individual events"),
|
category = Tool.TOOL_ANAL,
|
||||||
category=_("Analysis and Exploration"),
|
tool_class = EventComparison,
|
||||||
|
options_class = EventComparisonOptions,
|
||||||
|
modes = Tool.MODE_GUI,
|
||||||
|
translated_name = _("Compare individual events"),
|
||||||
|
author_name = "Donald N. Allingham",
|
||||||
|
author_email = "dallingham@users.sourceforge.net",
|
||||||
description=_("Aids in the analysis of data by allowing the "
|
description=_("Aids in the analysis of data by allowing the "
|
||||||
"development of custom filters that can be applied "
|
"development of custom filters that can be applied "
|
||||||
"to the database to find similar events")
|
"to the database to find similar events")
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ import soundex
|
|||||||
import NameDisplay
|
import NameDisplay
|
||||||
import ListModel
|
import ListModel
|
||||||
import MergePeople
|
import MergePeople
|
||||||
|
import Tool
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# Constants
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
_val2label = {
|
||||||
|
0.25 : _("Low"),
|
||||||
|
1.0 : _("Medium"),
|
||||||
|
2.0 : _("High"),
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@@ -70,10 +82,10 @@ def is_initial(name):
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
class Merge:
|
class Merge(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,database,callback,parent):
|
|
||||||
self.db = database
|
|
||||||
self.parent = parent
|
self.parent = parent
|
||||||
if self.parent.child_windows.has_key(self.__class__):
|
if self.parent.child_windows.has_key(self.__class__):
|
||||||
self.parent.child_windows[self.__class__].present(None)
|
self.parent.child_windows[self.__class__].present(None)
|
||||||
@@ -88,28 +100,31 @@ class Merge:
|
|||||||
self.update = callback
|
self.update = callback
|
||||||
self.use_soundex = 1
|
self.use_soundex = 1
|
||||||
|
|
||||||
self.family_list = database.get_family_handles()[:]
|
self.family_list = self.db.get_family_handles()[:]
|
||||||
self.person_list = database.get_person_handles(sort_handles=False)[:]
|
self.person_list = self.db.get_person_handles(sort_handles=False)[:]
|
||||||
|
|
||||||
base = os.path.dirname(__file__)
|
base = os.path.dirname(__file__)
|
||||||
self.glade_file = "%s/%s" % (base,"merge.glade")
|
self.glade_file = "%s/%s" % (base,"merge.glade")
|
||||||
top = gtk.glade.XML(self.glade_file,"dialog","gramps")
|
top = gtk.glade.XML(self.glade_file,"dialog","gramps")
|
||||||
|
|
||||||
|
# retrieve options
|
||||||
|
threshold = self.options.handler.options_dict['threshold']
|
||||||
|
use_soundex = self.options.handler.options_dict['soundex']
|
||||||
|
|
||||||
my_menu = gtk.Menu()
|
my_menu = gtk.Menu()
|
||||||
item = gtk.MenuItem(_("Low"))
|
vals = _val2label.keys()
|
||||||
item.set_data("v",0.25)
|
vals.sort()
|
||||||
item.show()
|
for val in vals:
|
||||||
my_menu.append(item)
|
item = gtk.MenuItem(_val2label[val])
|
||||||
item = gtk.MenuItem(_("Medium"))
|
item.set_data("v",val)
|
||||||
item.set_data("v",1.0)
|
|
||||||
item.show()
|
|
||||||
my_menu.append(item)
|
|
||||||
item = gtk.MenuItem(_("High"))
|
|
||||||
item.set_data("v",2.0)
|
|
||||||
item.show()
|
item.show()
|
||||||
my_menu.append(item)
|
my_menu.append(item)
|
||||||
|
my_menu.set_active(vals.index(threshold))
|
||||||
|
|
||||||
self.soundex_obj = top.get_widget("soundex")
|
self.soundex_obj = top.get_widget("soundex")
|
||||||
|
self.soundex_obj.set_active(use_soundex)
|
||||||
|
self.soundex_obj.show()
|
||||||
|
|
||||||
self.menu = top.get_widget("menu")
|
self.menu = top.get_widget("menu")
|
||||||
self.menu.set_menu(my_menu)
|
self.menu.set_menu(my_menu)
|
||||||
|
|
||||||
@@ -164,10 +179,16 @@ class Merge:
|
|||||||
self.ancestors_of(f1.get_mother_handle(),id_list)
|
self.ancestors_of(f1.get_mother_handle(),id_list)
|
||||||
|
|
||||||
def on_merge_ok_clicked(self,obj):
|
def on_merge_ok_clicked(self,obj):
|
||||||
active = self.menu.get_menu().get_active().get_data("v")
|
threshold = self.menu.get_menu().get_active().get_data("v")
|
||||||
self.use_soundex = self.soundex_obj.get_active()
|
self.use_soundex = int(self.soundex_obj.get_active())
|
||||||
self.close(obj)
|
self.close(obj)
|
||||||
self.find_potentials(active)
|
self.find_potentials(threshold)
|
||||||
|
|
||||||
|
self.options.handler.options_dict['threshold'] = threshold
|
||||||
|
self.options.handler.options_dict['soundex'] = self.use_soundex
|
||||||
|
# Save options
|
||||||
|
self.options.handler.save_options()
|
||||||
|
|
||||||
if len(self.map) == 0:
|
if len(self.map) == 0:
|
||||||
import QuestionDialog
|
import QuestionDialog
|
||||||
QuestionDialog.ErrorDialog(
|
QuestionDialog.ErrorDialog(
|
||||||
@@ -614,18 +635,6 @@ def get_name_obj(person):
|
|||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def runTool(database,active_person,callback,parent=None):
|
|
||||||
try:
|
|
||||||
Merge(database,callback,parent)
|
|
||||||
except:
|
|
||||||
import DisplayTrace
|
|
||||||
DisplayTrace.DisplayTrace()
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -634,6 +643,34 @@ def runTool(database,active_person,callback,parent=None):
|
|||||||
def by_id(p1,p2):
|
def by_id(p1,p2):
|
||||||
return cmp(p1.get_handle(),p2.get_handle())
|
return cmp(p1.get_handle(),p2.get_handle())
|
||||||
|
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
class MergeOptions(Tool.ToolOptions):
|
||||||
|
"""
|
||||||
|
Defines options and provides handling interface.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self,name,person_id=None):
|
||||||
|
Tool.ToolOptions.__init__(self,name,person_id)
|
||||||
|
|
||||||
|
def set_new_options(self):
|
||||||
|
# Options specific for this report
|
||||||
|
self.options_dict = {
|
||||||
|
'soundex' : 1,
|
||||||
|
'threshold' : 0.25,
|
||||||
|
}
|
||||||
|
self.options_help = {
|
||||||
|
'soundex' : ("=0/1","Whether to use SoundEx codes",
|
||||||
|
["Do not use SoundEx","Use SoundEx"],
|
||||||
|
True),
|
||||||
|
'threshold' : ("=num","Threshold for tolerance",
|
||||||
|
"Floating point number")
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@@ -642,9 +679,14 @@ def by_id(p1,p2):
|
|||||||
from PluginMgr import register_tool
|
from PluginMgr import register_tool
|
||||||
|
|
||||||
register_tool(
|
register_tool(
|
||||||
runTool,
|
name = 'dupfind',
|
||||||
_("Find possible duplicate people"),
|
category = Tool.TOOL_DBPROC,
|
||||||
category=_("Database Processing"),
|
tool_class = Merge,
|
||||||
|
options_class = MergeOptions,
|
||||||
|
modes = Tool.MODE_GUI,
|
||||||
|
translated_name = _("Find possible duplicate people"),
|
||||||
|
author_name = "Donald N. Allingham",
|
||||||
|
author_email = "dallingham@users.sourceforge.net",
|
||||||
description=_("Searches the entire database, looking for "
|
description=_("Searches the entire database, looking for "
|
||||||
"individual entries that may represent the same person.")
|
"individual entries that may represent the same person.")
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user