2002-10-20 19:55:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
# Copyright (C) 2000-2005 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-02-06 01:07:58 +05:30
|
|
|
# $Id$
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
"Database Processing/Merge people"
|
|
|
|
|
2002-11-17 04:52:33 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
# standard python models
|
2002-11-17 04:52:33 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
import os
|
2003-08-17 07:44:33 +05:30
|
|
|
from gettext import gettext as _
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-11-17 04:52:33 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
# GNOME libraries
|
2002-11-17 04:52:33 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
import gtk
|
|
|
|
import gtk.glade
|
2005-12-13 07:37:16 +05:30
|
|
|
import GrampsDisplay
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-11-17 04:52:33 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
# GRAMPS modules
|
2002-11-17 04:52:33 +05:30
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
import RelLib
|
|
|
|
import Utils
|
|
|
|
import soundex
|
|
|
|
import NameDisplay
|
|
|
|
import ListModel
|
2005-03-31 10:00:44 +05:30
|
|
|
import MergePeople
|
2006-03-11 06:42:06 +05:30
|
|
|
from PluginUtils import Tool, register_tool
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
# Constants
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
_val2label = {
|
|
|
|
0.25 : _("Low"),
|
|
|
|
1.0 : _("Medium"),
|
|
|
|
2.0 : _("High"),
|
|
|
|
}
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
def is_initial(name):
|
|
|
|
if len(name) > 2:
|
|
|
|
return 0
|
|
|
|
elif len(name) == 2:
|
2002-11-08 09:12:25 +05:30
|
|
|
if name[0] == name[0].upper() and name[1] == '.':
|
2002-10-20 19:55:16 +05:30
|
|
|
return 1
|
|
|
|
else:
|
2002-11-08 09:12:25 +05:30
|
|
|
return name[0] == name[0].upper()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
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)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-11 05:20:30 +05:30
|
|
|
self.parent = parent
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
if self.parent.child_windows.has_key(self.__class__):
|
|
|
|
self.parent.child_windows[self.__class__].present(None)
|
|
|
|
return
|
|
|
|
self.win_key = self.__class__
|
2002-10-20 19:55:16 +05:30
|
|
|
self.map = {}
|
|
|
|
self.list = []
|
|
|
|
self.index = 0
|
|
|
|
self.merger = None
|
|
|
|
self.mergee = None
|
|
|
|
self.removed = {}
|
|
|
|
self.update = callback
|
|
|
|
self.use_soundex = 1
|
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
self.family_list = self.db.get_family_handles()[:]
|
|
|
|
self.person_list = self.db.get_person_handles(sort_handles=False)[:]
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
base = os.path.dirname(__file__)
|
|
|
|
self.glade_file = "%s/%s" % (base,"merge.glade")
|
2003-08-17 07:44:33 +05:30
|
|
|
top = gtk.glade.XML(self.glade_file,"dialog","gramps")
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
# retrieve options
|
|
|
|
threshold = self.options.handler.options_dict['threshold']
|
|
|
|
use_soundex = self.options.handler.options_dict['soundex']
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
my_menu = gtk.Menu()
|
2005-12-06 12:08:09 +05:30
|
|
|
vals = _val2label.keys()
|
|
|
|
vals.sort()
|
|
|
|
for val in vals:
|
|
|
|
item = gtk.MenuItem(_val2label[val])
|
|
|
|
item.set_data("v",val)
|
|
|
|
item.show()
|
|
|
|
my_menu.append(item)
|
|
|
|
my_menu.set_active(vals.index(threshold))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
self.soundex_obj = top.get_widget("soundex")
|
2005-12-06 12:08:09 +05:30
|
|
|
self.soundex_obj.set_active(use_soundex)
|
|
|
|
self.soundex_obj.show()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.menu = top.get_widget("menu")
|
|
|
|
self.menu.set_menu(my_menu)
|
|
|
|
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.window = top.get_widget('dialog')
|
|
|
|
self.window.set_icon(self.parent.topWindow.get_icon())
|
|
|
|
Utils.set_titles(self.window, top.get_widget('title'),
|
2003-03-12 08:32:08 +05:30
|
|
|
_('Merge people'))
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
top.signal_autoconnect({
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"on_merge_ok_clicked" : self.on_merge_ok_clicked,
|
2004-05-11 05:20:30 +05:30
|
|
|
"destroy_passed_object" : self.close,
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"on_help_clicked" : self.on_help_clicked,
|
|
|
|
"on_delete_merge_event" : self.on_delete_event,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
2004-05-11 05:20:30 +05:30
|
|
|
self.add_itself_to_menu()
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.window.show()
|
|
|
|
|
|
|
|
def on_help_clicked(self,obj):
|
|
|
|
"""Display the relevant portion of GRAMPS manual"""
|
2005-12-13 07:37:16 +05:30
|
|
|
GrampsDisplay.help('tools-db')
|
2004-05-11 05:20:30 +05:30
|
|
|
|
|
|
|
def on_delete_event(self,obj,b):
|
|
|
|
self.remove_itself_from_menu()
|
|
|
|
|
|
|
|
def close(self,obj):
|
|
|
|
self.remove_itself_from_menu()
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.window.destroy()
|
2004-05-11 05:20:30 +05:30
|
|
|
|
|
|
|
def add_itself_to_menu(self):
|
|
|
|
self.parent.child_windows[self.win_key] = self
|
|
|
|
self.parent_menu_item = gtk.MenuItem(_('Merge people'))
|
|
|
|
self.parent_menu_item.connect("activate",self.present)
|
|
|
|
self.parent_menu_item.show()
|
|
|
|
self.parent.winsmenu.append(self.parent_menu_item)
|
|
|
|
|
|
|
|
def remove_itself_from_menu(self):
|
|
|
|
del self.parent.child_windows[self.win_key]
|
|
|
|
self.parent_menu_item.destroy()
|
|
|
|
|
|
|
|
def present(self,obj):
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.window.present()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
def ancestors_of(self,p1_id,id_list):
|
|
|
|
if (not p1_id) or (p1_id in id_list):
|
|
|
|
return
|
|
|
|
id_list.append(p1_id)
|
2004-08-07 10:46:57 +05:30
|
|
|
p1 = self.db.get_person_from_handle(p1_id)
|
2004-07-28 07:59:07 +05:30
|
|
|
f1_id = p1.get_main_parents_family_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if f1_id:
|
2004-08-20 03:05:16 +05:30
|
|
|
f1 = self.db.get_family_from_handle(f1_id)
|
2004-07-28 07:59:07 +05:30
|
|
|
self.ancestors_of(f1.get_father_handle(),id_list)
|
|
|
|
self.ancestors_of(f1.get_mother_handle(),id_list)
|
2004-05-09 22:02:13 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def on_merge_ok_clicked(self,obj):
|
2005-12-06 12:08:09 +05:30
|
|
|
threshold = self.menu.get_menu().get_active().get_data("v")
|
|
|
|
self.use_soundex = int(self.soundex_obj.get_active())
|
2004-05-11 05:20:30 +05:30
|
|
|
self.close(obj)
|
2005-12-06 12:08:09 +05:30
|
|
|
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()
|
|
|
|
|
2004-06-12 10:09:45 +05:30
|
|
|
if len(self.map) == 0:
|
|
|
|
import QuestionDialog
|
2005-03-31 10:00:44 +05:30
|
|
|
QuestionDialog.ErrorDialog(
|
|
|
|
_("No matches found"),
|
|
|
|
_("No potential duplicate people were found"))
|
2004-06-12 10:09:45 +05:30
|
|
|
else:
|
|
|
|
self.show()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def find_potentials(self,thresh):
|
2005-08-18 11:28:28 +05:30
|
|
|
self.progress = Utils.ProgressMeter(_('Find duplicates'),
|
2005-12-06 12:08:09 +05:30
|
|
|
_('Looking for duplicate people'))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
index = 0
|
|
|
|
males = {}
|
|
|
|
females = {}
|
2005-08-18 11:28:28 +05:30
|
|
|
|
|
|
|
length = len(self.person_list)
|
|
|
|
|
|
|
|
self.progress.set_pass(_('Pass 1: Building preliminary lists'),
|
|
|
|
length)
|
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
for p1_id in self.person_list:
|
2005-08-18 11:28:28 +05:30
|
|
|
self.progress.step()
|
2004-08-07 10:46:57 +05:30
|
|
|
p1 = self.db.get_person_from_handle(p1_id)
|
2004-02-14 11:10:30 +05:30
|
|
|
key = self.gen_key(p1.get_primary_name().get_surname())
|
2005-02-01 09:16:29 +05:30
|
|
|
if p1.get_gender() == RelLib.Person.MALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
if males.has_key(key):
|
2004-05-09 22:02:13 +05:30
|
|
|
males[key].append(p1_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-05-09 22:02:13 +05:30
|
|
|
males[key] = [p1_id]
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
if females.has_key(key):
|
2004-05-09 22:02:13 +05:30
|
|
|
females[key].append(p1_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-05-09 22:02:13 +05:30
|
|
|
females[key] = [p1_id]
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-08-18 11:28:28 +05:30
|
|
|
self.progress.set_pass(_('Pass 2: Calculating potential matches'),
|
|
|
|
length)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
for p1key in self.person_list:
|
2005-08-18 11:28:28 +05:30
|
|
|
self.progress.step()
|
2004-08-07 10:46:57 +05:30
|
|
|
p1 = self.db.get_person_from_handle(p1key)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
key = self.gen_key(p1.get_primary_name().get_surname())
|
2005-02-01 09:16:29 +05:30
|
|
|
if p1.get_gender() == RelLib.Person.MALE:
|
2002-10-20 19:55:16 +05:30
|
|
|
remaining = males[key]
|
|
|
|
else:
|
|
|
|
remaining = females[key]
|
|
|
|
|
|
|
|
index = 0
|
2002-11-08 09:12:25 +05:30
|
|
|
for p2key in remaining:
|
2002-10-20 19:55:16 +05:30
|
|
|
index = index + 1
|
2002-11-08 09:12:25 +05:30
|
|
|
if p1key == p2key:
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-08-07 10:46:57 +05:30
|
|
|
p2 = self.db.get_person_from_handle(p2key)
|
2002-11-08 09:12:25 +05:30
|
|
|
if self.map.has_key(p2key):
|
|
|
|
(v,c) = self.map[p2key]
|
2004-05-09 22:02:13 +05:30
|
|
|
if v == p1key:
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
|
|
|
|
|
|
|
chance = self.compare_people(p1,p2)
|
|
|
|
if chance >= thresh:
|
2002-11-08 09:12:25 +05:30
|
|
|
if self.map.has_key(p1key):
|
|
|
|
val = self.map[p1key]
|
2002-10-20 19:55:16 +05:30
|
|
|
if val[1] > chance:
|
2004-05-09 22:02:13 +05:30
|
|
|
self.map[p1key] = (p2key,chance)
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
2004-05-09 22:02:13 +05:30
|
|
|
self.map[p1key] = (p2key,chance)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
self.list = self.map.keys()
|
|
|
|
self.list.sort()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.length = len(self.list)
|
2005-08-18 11:28:28 +05:30
|
|
|
self.progress.close()
|
2002-10-20 19:55:16 +05:30
|
|
|
self.dellist = {}
|
|
|
|
|
|
|
|
def show(self):
|
2003-08-17 07:44:33 +05:30
|
|
|
top = gtk.glade.XML(self.glade_file,"mergelist","gramps")
|
2002-10-20 19:55:16 +05:30
|
|
|
self.window = top.get_widget("mergelist")
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.window.set_icon(self.parent.topWindow.get_icon())
|
2003-03-12 08:32:08 +05:30
|
|
|
|
|
|
|
Utils.set_titles(self.window, top.get_widget('title'),
|
|
|
|
_('Potential Merges'))
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.mlist = top.get_widget("mlist")
|
|
|
|
top.signal_autoconnect({
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
"destroy_passed_object" : self.close,
|
|
|
|
"on_do_merge_clicked" : self.on_do_merge_clicked,
|
|
|
|
"on_help_show_clicked" : self.on_help_clicked,
|
|
|
|
"on_delete_show_event" : self.on_delete_event,
|
2002-10-20 19:55:16 +05:30
|
|
|
})
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2002-11-17 04:52:33 +05:30
|
|
|
mtitles = [(_('Rating'),3,75),(_('First Person'),1,200),
|
|
|
|
(_('Second Person'),2,200),('',-1,0)]
|
|
|
|
self.list = ListModel.ListModel(self.mlist,mtitles,
|
|
|
|
event_func=self.on_do_merge_clicked)
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
self.redraw()
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
self.add_itself_to_menu()
|
2004-05-11 05:20:30 +05:30
|
|
|
self.window.show()
|
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
def redraw(self):
|
|
|
|
list = []
|
2004-05-09 22:02:13 +05:30
|
|
|
for p1key in self.map.keys():
|
|
|
|
if self.dellist.has_key(p1key):
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-05-09 22:02:13 +05:30
|
|
|
(p2key,c) = self.map[p1key]
|
|
|
|
if p1key == p2key:
|
2002-10-20 19:55:16 +05:30
|
|
|
continue
|
2004-05-09 22:02:13 +05:30
|
|
|
list.append((c,p1key,p2key))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2002-11-08 09:12:25 +05:30
|
|
|
self.list.clear()
|
2004-05-09 22:02:13 +05:30
|
|
|
for (c,p1key,p2key) in list:
|
2002-11-17 04:52:33 +05:30
|
|
|
c1 = "%5.2f" % c
|
|
|
|
c2 = "%5.2f" % (100-c)
|
2005-03-31 10:00:44 +05:30
|
|
|
p1 = self.db.get_person_from_handle(p1key)
|
|
|
|
p2 = self.db.get_person_from_handle(p2key)
|
|
|
|
if not p1 or not p2:
|
|
|
|
continue
|
|
|
|
pn1 = NameDisplay.displayer.display(p1)
|
|
|
|
pn2 = NameDisplay.displayer.display(p2)
|
2004-05-09 22:02:13 +05:30
|
|
|
self.list.add([c, pn1, pn2,c2],(p1key,p2key))
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def on_do_merge_clicked(self,obj):
|
2002-11-08 09:12:25 +05:30
|
|
|
store,iter = self.list.selection.get_selected()
|
|
|
|
if not iter:
|
2002-10-20 19:55:16 +05:30
|
|
|
return
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2005-03-31 10:00:44 +05:30
|
|
|
(self.p1,self.p2) = self.list.get_object(iter)
|
|
|
|
pn1 = self.db.get_person_from_handle(self.p1)
|
|
|
|
pn2 = self.db.get_person_from_handle(self.p2)
|
|
|
|
|
|
|
|
MergePeople.Compare(self.db,pn1,pn2,self.on_update)
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-03-31 10:00:44 +05:30
|
|
|
def on_update(self):
|
|
|
|
self.dellist[self.p2] = self.p1
|
2002-10-20 19:55:16 +05:30
|
|
|
for key in self.dellist.keys():
|
2005-03-31 10:00:44 +05:30
|
|
|
if self.dellist[key] == self.p2:
|
|
|
|
self.dellist[key] = self.p1
|
|
|
|
self.update(None,None)
|
2002-10-20 19:55:16 +05:30
|
|
|
self.redraw()
|
|
|
|
|
|
|
|
def update_and_destroy(self,obj):
|
|
|
|
self.update(1)
|
|
|
|
Utils.destroy_passed_object(obj)
|
|
|
|
|
|
|
|
def list_reduce(self,list1,list2):
|
|
|
|
value = 0
|
|
|
|
for name in list1:
|
|
|
|
for name2 in list2:
|
|
|
|
if is_initial(name) and name[0] == name2[0]:
|
|
|
|
value = value + 0.25
|
|
|
|
break
|
|
|
|
if is_initial(name2) and name2[0] == name[0]:
|
|
|
|
value = value + 0.25
|
|
|
|
break
|
|
|
|
if name == name2:
|
|
|
|
value = value + 0.5
|
|
|
|
break
|
|
|
|
if name[0] == name2[0] and self.name_compare(name,name2):
|
|
|
|
value = value + 0.25
|
|
|
|
break
|
|
|
|
if value == 0:
|
|
|
|
return -1
|
|
|
|
else:
|
|
|
|
return min(value,1)
|
|
|
|
|
|
|
|
def gen_key(self,val):
|
|
|
|
if self.use_soundex:
|
2004-02-06 01:07:58 +05:30
|
|
|
try:
|
|
|
|
return soundex.soundex(val)
|
|
|
|
except UnicodeEncodeError:
|
|
|
|
return val
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
return val
|
|
|
|
|
|
|
|
def name_compare(self,s1,s2):
|
|
|
|
if self.use_soundex:
|
2004-02-06 01:07:58 +05:30
|
|
|
try:
|
|
|
|
return soundex.compare(s1,s2)
|
|
|
|
except UnicodeEncodeError:
|
|
|
|
return s1 == s2
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
return s1 == s2
|
|
|
|
|
|
|
|
def date_match(self,date1,date2):
|
2005-12-13 07:37:16 +05:30
|
|
|
if date1.is_empty() or date2.is_empty():
|
2002-10-20 19:55:16 +05:30
|
|
|
return 0
|
2004-10-03 04:37:43 +05:30
|
|
|
if date1.is_equal(date2):
|
2002-10-20 19:55:16 +05:30
|
|
|
return 1
|
|
|
|
|
2004-10-03 04:37:43 +05:30
|
|
|
if date1.is_compound() or date2.is_compound():
|
2002-10-20 19:55:16 +05:30
|
|
|
return self.range_compare(date1,date2)
|
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
if date1.get_year() == date2.get_year():
|
|
|
|
if date1.get_month() == date2.get_month():
|
2002-10-20 19:55:16 +05:30
|
|
|
return 0.75
|
2004-05-09 22:02:13 +05:30
|
|
|
if not date1.get_month_valid() or not date2.get_month_valid():
|
2002-10-20 19:55:16 +05:30
|
|
|
return 0.75
|
|
|
|
else:
|
|
|
|
return -1
|
|
|
|
else:
|
|
|
|
return -1
|
|
|
|
|
|
|
|
def range_compare(self,date1,date2):
|
2004-10-03 04:37:43 +05:30
|
|
|
start_date_1 = date1.get_start_date()[0:3]
|
|
|
|
start_date_2 = date2.get_start_date()[0:3]
|
|
|
|
stop_date_1 = date1.get_stop_date()[0:3]
|
|
|
|
stop_date_2 = date2.get_stop_date()[0:3]
|
|
|
|
if date1.is_compound() and date2.is_compound():
|
|
|
|
if start_date_1 >= start_date_2 and start_date_1 <= stop_date_2 or \
|
|
|
|
start_date_2 >= start_date_1 and start_date_2 <= stop_date_1 or \
|
|
|
|
stop_date_1 >= start_date_2 and stop_date_1 <= stop_date_2 or \
|
|
|
|
stop_date_2 >= start_date_1 and stop_date_2 <= stop_date_1:
|
2002-10-20 19:55:16 +05:30
|
|
|
return 0.5
|
|
|
|
else:
|
|
|
|
return -1
|
2004-10-03 04:37:43 +05:30
|
|
|
elif date2.is_compound():
|
|
|
|
if start_date_1 >= start_date_2 and start_date_1 <= stop_date_2:
|
2002-10-20 19:55:16 +05:30
|
|
|
return 0.5
|
|
|
|
else:
|
|
|
|
return -1
|
|
|
|
else:
|
2004-10-03 04:37:43 +05:30
|
|
|
if start_date_2 >= start_date_1 and start_date_2 <= stop_date_1:
|
2002-10-20 19:55:16 +05:30
|
|
|
return 0.5
|
|
|
|
else:
|
|
|
|
return -1
|
|
|
|
|
|
|
|
def name_match(self,name,name1):
|
|
|
|
|
|
|
|
if not name1 or not name:
|
|
|
|
return 0
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
srn1 = name.get_surname()
|
|
|
|
sfx1 = name.get_suffix()
|
|
|
|
srn2 = name1.get_surname()
|
|
|
|
sfx2 = name1.get_suffix()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if not self.name_compare(srn1,srn2):
|
|
|
|
return -1
|
|
|
|
if sfx1 != sfx2:
|
|
|
|
if sfx1 != "" and sfx2 != "":
|
|
|
|
return -1
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
if name.get_first_name() == name1.get_first_name():
|
2002-10-20 19:55:16 +05:30
|
|
|
return 1
|
|
|
|
else:
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
list1 = name.get_first_name().split()
|
|
|
|
list2 = name1.get_first_name().split()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
if len(list1) < len(list2):
|
|
|
|
return self.list_reduce(list1,list2)
|
|
|
|
else:
|
|
|
|
return self.list_reduce(list2,list1)
|
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
def place_match(self,p1_id,p2_id):
|
|
|
|
if p1_id == p2_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
return 1
|
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
if not p1_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
name1 = ""
|
|
|
|
else:
|
2004-08-07 10:46:57 +05:30
|
|
|
p1 = self.db.get_place_from_handle(p1_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
name1 = p1.get_title()
|
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
if not p2_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
name2 = ""
|
|
|
|
else:
|
2004-08-07 10:46:57 +05:30
|
|
|
p2 = self.db.get_place_from_handle(p2_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
name2 = p2.get_title()
|
|
|
|
|
2004-05-09 22:02:13 +05:30
|
|
|
if not (name1 and name2):
|
2002-10-20 19:55:16 +05:30
|
|
|
return 0
|
|
|
|
if name1 == name2:
|
|
|
|
return 1
|
|
|
|
|
* src/gramps_main.py (tool_callback): Typo.
* src/QuestionDialog.py: Use gramps icon.
* src/plugins/EventCmp.py: HIG; single instance; help.
* src/plugins/eventcmp.glade: HIG; help.
* src/plugins/Desbrowser.py: HIG, help, rebuild model after edit.
* src/plugins/desbrowse.glade: help, info label.
* src/plugins/PatchNames.py: HIG, help, single instance.
* src/plugins/patchnames.glade: HIG, help.
* src/plugins/Merge.py: HIG, help, single instance.
* src/plugins/merge.glade: HIG, help.
* src/plugins/ChangeNames.py: HIG, help, single instance.
svn: r4230
2005-03-24 11:52:25 +05:30
|
|
|
list1 = name1.replace(","," ").split()
|
|
|
|
list2 = name2.replace(","," ").split()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
value = 0
|
|
|
|
for name in list1:
|
|
|
|
for name2 in list2:
|
|
|
|
if name == name2:
|
|
|
|
value = value + 0.5
|
|
|
|
break
|
|
|
|
if name[0] == name2[0] and self.name_compare(name,name2):
|
|
|
|
value = value + 0.25
|
|
|
|
break
|
|
|
|
if value == 0:
|
|
|
|
return -1
|
|
|
|
else:
|
|
|
|
return min(value,1)
|
|
|
|
|
|
|
|
def compare_people(self,p1,p2):
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
name1 = p1.get_primary_name()
|
|
|
|
name2 = p2.get_primary_name()
|
2002-11-08 09:12:25 +05:30
|
|
|
|
2002-10-20 19:55:16 +05:30
|
|
|
chance = self.name_match(name1,name2)
|
|
|
|
if chance == -1 :
|
|
|
|
return -1
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
birth1_id = p1.get_birth_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if birth1_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
birth1 = self.db.get_event_from_handle(birth1_id)
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
birth1 = RelLib.Event()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
death1_id = p1.get_death_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if death1_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
death1 = self.db.get_event_from_handle(death1_id)
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
death1 = RelLib.Event()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
birth2_id = p2.get_birth_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if birth2_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
birth2 = self.db.get_event_from_handle(birth2_id)
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
birth2 = RelLib.Event()
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
death2_id = p2.get_death_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if death2_id:
|
* src/AddSpouse.py, src/ChooseParents.py, src/EditPerson.py,
src/EditPlace.py, src/EditSource.py, src/EventEdit.py,
src/FamilyView.py, src/GenericFilter.py,
src/Marriage.py, src/PedView.py, src/PeopleModel.py,
src/PlaceView.py, src/RelLib.py, src/SelectChild.py,
src/Sort.py, src/SourceView.py, src/SubstKeywords.py,
src/WriteGedcom.py, src/WriteXML.py, src/plugins/AncestorReport.py,
src/plugins/Ancestors.py, src/plugins/ChangeTypes.py,
src/plugins/DescendReport.py, src/plugins/DetDescendantReport.py,
src/plugins/EventCmp.py, src/plugins/FamilyGroup.py,
src/plugins/FanChart.py, src/plugins/FtmStyleAncestors.py,
src/plugins/FtmStyleDescendants.py, src/plugins/GraphViz.py,
src/plugins/IndivComplete.py, src/plugins/IndivSummary.py,
src/plugins/Merge.py, src/plugins/RelCalc.py, src/plugins/RelGraph.py,
src/plugins/Summary.py, src/plugins/TimeLine.py, src/plugins/Verify.py,
src/plugins/WebPage.py, src/plugins/WriteCD.py,
src/plugins/WritePkg.py, src/plugins/DetAncestralReport.py:
Use get_event_from_handle (not find_ ).
svn: r3462
2004-08-22 00:26:01 +05:30
|
|
|
death2 = self.db.get_event_from_handle(death2_id)
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
death2 = RelLib.Event()
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-13 07:37:16 +05:30
|
|
|
value = self.date_match(birth1.get_date_object(),birth2.get_date_object())
|
2002-10-20 19:55:16 +05:30
|
|
|
if value == -1 :
|
|
|
|
return -1
|
|
|
|
chance = chance + value
|
|
|
|
|
2004-02-14 11:10:30 +05:30
|
|
|
value = self.date_match(death1.get_date_object(),death2.get_date_object())
|
2002-10-20 19:55:16 +05:30
|
|
|
if value == -1 :
|
|
|
|
return -1
|
|
|
|
chance = chance + value
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
value = self.place_match(birth1.get_place_handle(),birth2.get_place_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
if value == -1 :
|
|
|
|
return -1
|
|
|
|
chance = chance + value
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
value = self.place_match(death1.get_place_handle(),death2.get_place_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
if value == -1 :
|
|
|
|
return -1
|
|
|
|
chance = chance + value
|
|
|
|
|
|
|
|
ancestors = []
|
2004-07-28 07:59:07 +05:30
|
|
|
self.ancestors_of(p1.get_handle(),ancestors)
|
|
|
|
if p2.get_handle() in ancestors:
|
2002-10-20 19:55:16 +05:30
|
|
|
return -1
|
|
|
|
|
|
|
|
ancestors = []
|
2004-07-28 07:59:07 +05:30
|
|
|
self.ancestors_of(p2.get_handle(),ancestors)
|
|
|
|
if p1.get_handle() in ancestors:
|
2002-10-20 19:55:16 +05:30
|
|
|
return -1
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
f1_id = p1.get_main_parents_family_handle()
|
|
|
|
f2_id = p2.get_main_parents_family_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
|
|
|
|
if f1_id and f2_id:
|
2004-08-20 03:05:16 +05:30
|
|
|
f1 = self.db.get_family_from_handle(f1_id)
|
|
|
|
f2 = self.db.get_family_from_handle(f2_id)
|
2004-07-28 07:59:07 +05:30
|
|
|
dad1_id = f1.get_father_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if dad1_id:
|
2004-08-07 10:46:57 +05:30
|
|
|
dad1 = get_name_obj(self.db.get_person_from_handle(dad1_id))
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
dad1 = None
|
2004-07-28 07:59:07 +05:30
|
|
|
dad2_id = f2.get_father_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if dad2_id:
|
2004-08-07 10:46:57 +05:30
|
|
|
dad2 = get_name_obj(self.db.get_person_from_handle(dad2_id))
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
dad2 = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
value = self.name_match(dad1,dad2)
|
|
|
|
|
|
|
|
if value == -1:
|
|
|
|
return -1
|
|
|
|
|
|
|
|
chance = chance + value
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
mom1_id = f1.get_mother_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if mom1_id:
|
2004-08-07 10:46:57 +05:30
|
|
|
mom1 = get_name_obj(self.db.get_person_from_handle(mom1_id))
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
mom1 = None
|
2004-07-28 07:59:07 +05:30
|
|
|
mom2_id = f2.get_mother_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if mom2_id:
|
2004-08-07 10:46:57 +05:30
|
|
|
mom2 = get_name_obj(self.db.get_person_from_handle(mom2_id))
|
2004-05-09 22:02:13 +05:30
|
|
|
else:
|
|
|
|
mom2 = None
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
value = self.name_match(mom1,mom2)
|
|
|
|
if value == -1:
|
|
|
|
return -1
|
|
|
|
|
|
|
|
chance = chance + value
|
|
|
|
|
2004-07-28 07:59:07 +05:30
|
|
|
for f1_id in p1.get_family_handle_list():
|
2004-08-20 03:05:16 +05:30
|
|
|
f1 = self.db.get_family_from_handle(f1_id)
|
2004-07-28 07:59:07 +05:30
|
|
|
for f2_id in p2.get_family_handle_list():
|
2004-08-20 03:05:16 +05:30
|
|
|
f2 = self.db.get_family_from_handle(f2_id)
|
2005-02-01 09:16:29 +05:30
|
|
|
if p1.get_gender() == RelLib.Person.FEMALE:
|
2004-07-28 07:59:07 +05:30
|
|
|
father1_id = f1.get_father_handle()
|
|
|
|
father2_id = f2.get_father_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if father1_id and father2_id:
|
|
|
|
if father1_id == father2_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
chance = chance + 1
|
|
|
|
else:
|
2004-08-07 10:46:57 +05:30
|
|
|
father1 = self.db.get_person_from_handle(father1_id)
|
|
|
|
father2 = self.db.get_person_from_handle(father2_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
fname1 = get_name_obj(father1)
|
|
|
|
fname2 = get_name_obj(father2)
|
|
|
|
value = self.name_match(fname1,fname2)
|
|
|
|
if value != -1:
|
|
|
|
chance = chance + value
|
|
|
|
else:
|
2004-07-28 07:59:07 +05:30
|
|
|
mother1_id = f1.get_mother_handle()
|
|
|
|
mother2_id = f2.get_mother_handle()
|
2004-05-09 22:02:13 +05:30
|
|
|
if mother1_id and mother2_id:
|
|
|
|
if mother1_id == mother2_id:
|
2002-10-20 19:55:16 +05:30
|
|
|
chance = chance + 1
|
|
|
|
else:
|
2004-08-07 10:46:57 +05:30
|
|
|
mother1 = self.db.get_person_from_handle(mother1_id)
|
|
|
|
mother2 = self.db.get_person_from_handle(mother2_id)
|
2002-10-20 19:55:16 +05:30
|
|
|
mname1 = get_name_obj(mother1)
|
|
|
|
mname2 = get_name_obj(mother2)
|
|
|
|
value = self.name_match(mname1,mname2)
|
|
|
|
if value != -1:
|
|
|
|
chance = chance + value
|
|
|
|
return chance
|
|
|
|
|
2004-05-11 05:20:30 +05:30
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
def name_of(p):
|
|
|
|
if not p:
|
|
|
|
return ""
|
2005-01-01 09:57:15 +05:30
|
|
|
return "%s (%s)" % (NameDisplay.displayer.display(p),p.get_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
def get_name_obj(person):
|
|
|
|
if person:
|
2004-02-14 11:10:30 +05:30
|
|
|
return person.get_primary_name()
|
2002-10-20 19:55:16 +05:30
|
|
|
else:
|
|
|
|
return None
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
2005-12-06 12:08:09 +05:30
|
|
|
def by_id(p1,p2):
|
|
|
|
return cmp(p1.get_handle(),p2.get_handle())
|
2002-10-20 19:55:16 +05:30
|
|
|
|
2005-12-06 12:08:09 +05:30
|
|
|
|
|
|
|
#------------------------------------------------------------------------
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
2005-12-06 12:08:09 +05:30
|
|
|
#
|
2002-10-20 19:55:16 +05:30
|
|
|
#
|
2005-12-06 12:08:09 +05:30
|
|
|
#------------------------------------------------------------------------
|
|
|
|
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")
|
|
|
|
}
|
2002-10-20 19:55:16 +05:30
|
|
|
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#-------------------------------------------------------------------------
|
|
|
|
register_tool(
|
2005-12-06 12:08:09 +05:30
|
|
|
name = 'dupfind',
|
|
|
|
category = Tool.TOOL_DBPROC,
|
|
|
|
tool_class = Merge,
|
|
|
|
options_class = MergeOptions,
|
|
|
|
modes = Tool.MODE_GUI,
|
|
|
|
translated_name = _("Find possible duplicate people"),
|
|
|
|
status = _("Stable"),
|
|
|
|
author_name = "Donald N. Allingham",
|
|
|
|
author_email = "don@gramps-project.org",
|
2002-11-08 09:12:25 +05:30
|
|
|
description=_("Searches the entire database, looking for "
|
|
|
|
"individual entries that may represent the same person.")
|
2002-10-20 19:55:16 +05:30
|
|
|
)
|