Find Duplicate People Pylint
This commit is contained in:
@ -65,6 +65,7 @@ _val2label = {
|
|||||||
WIKI_HELP_PAGE = '%s_-_Tools' % URL_MANUAL_PAGE
|
WIKI_HELP_PAGE = '%s_-_Tools' % URL_MANUAL_PAGE
|
||||||
WIKI_HELP_SEC = _('manual|Find_Possible_Duplicate_People')
|
WIKI_HELP_SEC = _('manual|Find_Possible_Duplicate_People')
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -79,6 +80,7 @@ def is_initial(name):
|
|||||||
else:
|
else:
|
||||||
return name[0] == name[0].upper()
|
return name[0] == name[0].upper()
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# The Actual tool.
|
# The Actual tool.
|
||||||
@ -90,8 +92,7 @@ class DuplicatePeopleTool(tool.Tool, ManagedWindow):
|
|||||||
uistate = user.uistate
|
uistate = user.uistate
|
||||||
|
|
||||||
tool.Tool.__init__(self, dbstate, options_class, name)
|
tool.Tool.__init__(self, dbstate, options_class, name)
|
||||||
ManagedWindow.__init__(self, uistate, [],
|
ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||||
self.__class__)
|
|
||||||
self.dbstate = dbstate
|
self.dbstate = dbstate
|
||||||
self.uistate = uistate
|
self.uistate = uistate
|
||||||
self.map = {}
|
self.map = {}
|
||||||
@ -139,10 +140,10 @@ class DuplicatePeopleTool(tool.Tool, ManagedWindow):
|
|||||||
|
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def build_menu_names(self, obj):
|
def build_menu_names(self, _obj):
|
||||||
return (_("Tool settings"), _("Find Duplicates tool"))
|
return (_("Tool settings"), _("Find Duplicates tool"))
|
||||||
|
|
||||||
def on_help_clicked(self, obj):
|
def on_help_clicked(self, _obj):
|
||||||
"""Display the relevant portion of Gramps manual"""
|
"""Display the relevant portion of Gramps manual"""
|
||||||
|
|
||||||
display_help(WIKI_HELP_PAGE , WIKI_HELP_SEC)
|
display_help(WIKI_HELP_PAGE , WIKI_HELP_SEC)
|
||||||
@ -374,28 +375,28 @@ class DuplicatePeopleTool(tool.Tool, ManagedWindow):
|
|||||||
for f2_id in p2.get_family_handle_list():
|
for f2_id in p2.get_family_handle_list():
|
||||||
f2 = self.db.get_family_from_handle(f2_id)
|
f2 = self.db.get_family_from_handle(f2_id)
|
||||||
if p1.get_gender() == Person.FEMALE:
|
if p1.get_gender() == Person.FEMALE:
|
||||||
father1_id = f1.get_father_handle()
|
father1_h = f1.get_father_handle()
|
||||||
father2_id = f2.get_father_handle()
|
father2_h = f2.get_father_handle()
|
||||||
if father1_id and father2_id:
|
if father1_h and father2_h:
|
||||||
if father1_id == father2_id:
|
if father1_h == father2_h:
|
||||||
chance += 1
|
chance += 1
|
||||||
else:
|
else:
|
||||||
father1 = self.db.get_person_from_handle(father1_id)
|
father1 = self.db.get_person_from_handle(father1_h)
|
||||||
father2 = self.db.get_person_from_handle(father2_id)
|
father2 = self.db.get_person_from_handle(father2_h)
|
||||||
fname1 = get_name_obj(father1)
|
fname1 = get_name_obj(father1)
|
||||||
fname2 = get_name_obj(father2)
|
fname2 = get_name_obj(father2)
|
||||||
value = self.name_match(fname1, fname2)
|
value = self.name_match(fname1, fname2)
|
||||||
if value != -1:
|
if value != -1:
|
||||||
chance += value
|
chance += value
|
||||||
else:
|
else:
|
||||||
mother1_id = f1.get_mother_handle()
|
mother1_h = f1.get_mother_handle()
|
||||||
mother2_id = f2.get_mother_handle()
|
mother2_h = f2.get_mother_handle()
|
||||||
if mother1_id and mother2_id:
|
if mother1_h and mother2_h:
|
||||||
if mother1_id == mother2_id:
|
if mother1_h == mother2_h:
|
||||||
chance += 1
|
chance += 1
|
||||||
else:
|
else:
|
||||||
mother1 = self.db.get_person_from_handle(mother1_id)
|
mother1 = self.db.get_person_from_handle(mother1_h)
|
||||||
mother2 = self.db.get_person_from_handle(mother2_id)
|
mother2 = self.db.get_person_from_handle(mother2_h)
|
||||||
mname1 = get_name_obj(mother1)
|
mname1 = get_name_obj(mother1)
|
||||||
mname2 = get_name_obj(mother2)
|
mname2 = get_name_obj(mother2)
|
||||||
value = self.name_match(mname1, mname2)
|
value = self.name_match(mname1, mname2)
|
||||||
@ -569,8 +570,7 @@ class DuplicatePeopleToolMatches(ManagedWindow):
|
|||||||
})
|
})
|
||||||
self.db.connect("person-delete", self.person_delete)
|
self.db.connect("person-delete", self.person_delete)
|
||||||
|
|
||||||
mtitles = [
|
mtitles = [(_('Rating'), 3, 75),
|
||||||
(_('Rating'),3,75),
|
|
||||||
(_('First Person'), 1, 200),
|
(_('First Person'), 1, 200),
|
||||||
(_('Second Person'), 2, 200),
|
(_('Second Person'), 2, 200),
|
||||||
('', -1, 0)
|
('', -1, 0)
|
||||||
@ -581,10 +581,10 @@ class DuplicatePeopleToolMatches(ManagedWindow):
|
|||||||
self.redraw()
|
self.redraw()
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def build_menu_names(self, obj):
|
def build_menu_names(self, _obj):
|
||||||
return (_("Merge candidates"), _("Merge persons"))
|
return (_("Merge candidates"), _("Merge persons"))
|
||||||
|
|
||||||
def on_help_clicked(self, obj):
|
def on_help_clicked(self, _obj):
|
||||||
"""Display the relevant portion of Gramps manual"""
|
"""Display the relevant portion of Gramps manual"""
|
||||||
|
|
||||||
display_help(WIKI_HELP_PAGE , WIKI_HELP_SEC)
|
display_help(WIKI_HELP_PAGE , WIKI_HELP_SEC)
|
||||||
@ -612,12 +612,12 @@ class DuplicatePeopleToolMatches(ManagedWindow):
|
|||||||
pn2 = name_displayer.display(p2)
|
pn2 = name_displayer.display(p2)
|
||||||
self.list.add([c1, pn1, pn2,c2],(p1key,p2key))
|
self.list.add([c1, pn1, pn2,c2],(p1key,p2key))
|
||||||
|
|
||||||
def on_do_merge_clicked(self, obj):
|
def on_do_merge_clicked(self, _obj):
|
||||||
store,iter = self.list.selection.get_selected()
|
_store, iter_ = self.list.selection.get_selected()
|
||||||
if not iter:
|
if not iter_:
|
||||||
return
|
return
|
||||||
|
|
||||||
(self.p1,self.p2) = self.list.get_object(iter)
|
(self.p1, self.p2) = self.list.get_object(iter_)
|
||||||
MergePerson(self.dbstate, self.uistate, self.track, self.p1, self.p2,
|
MergePerson(self.dbstate, self.uistate, self.track, self.p1, self.p2,
|
||||||
self.on_update, True)
|
self.on_update, True)
|
||||||
|
|
||||||
@ -630,7 +630,7 @@ class DuplicatePeopleToolMatches(ManagedWindow):
|
|||||||
self.update()
|
self.update()
|
||||||
self.redraw()
|
self.redraw()
|
||||||
|
|
||||||
def update_and_destroy(self, obj):
|
def update_and_destroy(self, _obj):
|
||||||
self.update(1)
|
self.update(1)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
@ -656,16 +656,19 @@ def name_of(p):
|
|||||||
return ""
|
return ""
|
||||||
return "%s (%s)" % (name_displayer.display(p), p.get_handle())
|
return "%s (%s)" % (name_displayer.display(p), p.get_handle())
|
||||||
|
|
||||||
|
|
||||||
def get_name_obj(person):
|
def get_name_obj(person):
|
||||||
if person:
|
if person:
|
||||||
return person.get_primary_name()
|
return person.get_primary_name()
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_surnames(name):
|
def get_surnames(name):
|
||||||
"""Construct a full surname of the surnames"""
|
"""Construct a full surname of the surnames"""
|
||||||
return ' '.join([surn.get_surname() for surn in name.get_surname_list()])
|
return ' '.join([surn.get_surname() for surn in name.get_surname_list()])
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
Reference in New Issue
Block a user