From 7c3bcc5f060e665ecfec4cc184b1042ce7ae5f7c Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 24 Jan 2011 18:55:52 +0000 Subject: [PATCH] Remove redundant line continuations svn: r16459 --- src/plugins/tool/Check.py | 31 ++++++++++++++++++------------- src/plugins/tool/EventCmp.py | 7 ++++--- src/plugins/tool/FindDupes.py | 11 ++++++----- src/plugins/tool/NotRelated.py | 4 ++-- src/plugins/tool/Verify.py | 8 ++++---- 5 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/plugins/tool/Check.py b/src/plugins/tool/Check.py index 7ca8e5ab4..2bbe99724 100644 --- a/src/plugins/tool/Check.py +++ b/src/plugins/tool/Check.py @@ -36,6 +36,7 @@ import cStringIO from gen.ggettext import gettext as _ from gen.ggettext import ngettext +from collections import defaultdict #------------------------------------------------------------------------ # @@ -108,15 +109,17 @@ def _table_low_level(db,table): """ Low level repair for a given db table. """ - handle_list = table.keys() - dup_handles = set( - [ handle for handle in handle_list if handle_list.count(handle) > 1 ] - ) - if not dup_handles: + handle_list = table.keys() + handle_dict = defaultdict(int) + for key in handle_list: + handle_dict[key] += 1 + + if len(handle_dict) == len(handle_list): print " No duplicates found for this table" return True - + dup_handles = [handle for handle, count in handle_dict.items() + if count > 1] # import gen.db from gen.db import DbBsddbAssocCursor table_cursor = DbBsddbAssocCursor(table) @@ -250,10 +253,11 @@ class CheckIntegrity(object): self.progress = ProgressMeter(_('Checking Database'),'') def family_errors(self): - return len(self.broken_parent_links) + \ - len(self.broken_links) + \ - len(self.empty_family) + \ + return (len(self.broken_parent_links) + + len(self.broken_links) + + len(self.empty_family) + len(self.duplicate_links) + ) def cleanup_deleted_name_formats(self): """ @@ -372,7 +376,9 @@ class CheckIntegrity(object): fhandle_list = self.db.get_family_handles() self.progress.set_pass(_('Looking for broken family links'), - len(fhandle_list) + self.db.get_number_of_people()) + len(fhandle_list) + + self.db.get_number_of_people() + ) for family_handle in fhandle_list: family = self.db.get_family_from_handle(family_handle) @@ -760,9 +766,8 @@ class CheckIntegrity(object): else: mgender = None - if (fgender == gen.lib.Person.FEMALE \ - or mgender == gen.lib.Person.MALE) \ - and fgender != mgender: + if (fgender == gen.lib.Person.FEMALE + or mgender == gen.lib.Person.MALE) and fgender != mgender: # swap. note: (at most) one handle may be None family.set_father_handle(mother_handle) family.set_mother_handle(father_handle) diff --git a/src/plugins/tool/EventCmp.py b/src/plugins/tool/EventCmp.py index 52ee39d01..2f8325e05 100644 --- a/src/plugins/tool/EventCmp.py +++ b/src/plugins/tool/EventCmp.py @@ -333,12 +333,13 @@ class DisplayChart(ManagedWindow.ManagedWindow): if event_handle: event = self.db.get_event_from_handle(event_handle) date = DateHandler.get_date(event) - sortdate = "%09d" % \ + sortdate = "%09d" % ( event.get_date_object().get_sort_value() + ) place_handle = event.get_place_handle() if place_handle: - place = self.db. \ - get_place_from_handle(place_handle).get_title() + place = self.db.get_place_from_handle( + place_handle).get_title() tlist += [date, sortdate, place] added = True else: diff --git a/src/plugins/tool/FindDupes.py b/src/plugins/tool/FindDupes.py index 14bfef653..27160fb31 100644 --- a/src/plugins/tool/FindDupes.py +++ b/src/plugins/tool/FindDupes.py @@ -183,7 +183,8 @@ class Merge(tool.Tool,ManagedWindow.ManagedWindow): def find_potentials(self, thresh): self.progress = ProgressMeter(_('Find Duplicates'), - _('Looking for duplicate people')) + _('Looking for duplicate people') + ) index = 0 males = {} @@ -431,10 +432,10 @@ class Merge(tool.Tool,ManagedWindow.ManagedWindow): 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_2 <= start_date_1 <= stop_date_2 or \ - start_date_1 <= start_date_2 <= stop_date_1 or \ - start_date_2 <= stop_date_1 <= stop_date_2 or \ - start_date_1 <= stop_date_2 <= stop_date_1: + if (start_date_2 <= start_date_1 <= stop_date_2 or + start_date_1 <= start_date_2 <= stop_date_1 or + start_date_2 <= stop_date_1 <= stop_date_2 or + start_date_1 <= stop_date_2 <= stop_date_1): return 0.5 else: return -1 diff --git a/src/plugins/tool/NotRelated.py b/src/plugins/tool/NotRelated.py index a0247af0c..23836fe54 100644 --- a/src/plugins/tool/NotRelated.py +++ b/src/plugins/tool/NotRelated.py @@ -364,8 +364,8 @@ class NotRelated(tool.ActivePersonTool, ManagedWindow.ManagedWindow) : # update our numbers self.numberOfRelatedPeople = len(self.handlesOfPeopleAlreadyProcessed) - self.numberOfUnrelatedPeople = self.numberOfPeopleInDatabase - \ - self.numberOfRelatedPeople + self.numberOfUnrelatedPeople = (self.numberOfPeopleInDatabase - + self.numberOfRelatedPeople) if self.numberOfUnrelatedPeople > 0: # we have at least 1 "unrelated" person to find diff --git a/src/plugins/tool/Verify.py b/src/plugins/tool/Verify.py index 1a9155c4a..e3c8081b5 100644 --- a/src/plugins/tool/Verify.py +++ b/src/plugins/tool/Verify.py @@ -990,12 +990,12 @@ class TooManyChildren(PersonRule): def broken(self): n_child = get_n_children(self.db,self.obj) - if (self.obj.get_gender == gen.lib.Person.MALE) \ - and (n_child > self.mx_child_dad): + if (self.obj.get_gender == gen.lib.Person.MALE + and n_child > self.mx_child_dad): return True - if (self.obj.get_gender == gen.lib.Person.FEMALE) \ - and (n_child > self.mx_child_mom): + if (self.obj.get_gender == gen.lib.Person.FEMALE + and n_child > self.mx_child_mom): return True return False