diff --git a/src/ScratchPad.py b/src/ScratchPad.py index 48ec0eb63..eede08b9b 100644 --- a/src/ScratchPad.py +++ b/src/ScratchPad.py @@ -287,7 +287,8 @@ class ScratchAddress(ScratchObjWrapper): self._value = "%s %s %s %s" % (self._obj.get_street(), self._obj.get_city(), self._obj.get_state(), - self._obj.get_country()) + self._obj.get_country(), + ) class ScratchLocation(ScratchObjWrapper): @@ -300,7 +301,8 @@ class ScratchLocation(ScratchObjWrapper): self._type = _("Location") self._value = "%s %s %s" % (self._obj.get_city(), self._obj.get_state(), - self._obj.get_country()) + self._obj.get_country(), + ) class ScratchEvent(ScratchHandleWrapper): @@ -446,7 +448,7 @@ class ScratchSourceRef(ScratchObjWrapper): self._title = base.get_title() notelist = map(self._db.get_note_from_handle, self._obj.get_note_list()) - srctxtlist = [ note for note in notelist + srctxtlist = [note for note in notelist if note.get_type() == gen.lib.NoteType.SOURCE_TEXT] page = self._obj.get_page() if not page: @@ -1076,7 +1078,7 @@ class ScratchPadListView(object): if dragtype in self._target_type_to_wrapper_class_map: possible_wrappers = [dragtype] else: - possible_wrappers = [target for target in context.targets \ + possible_wrappers = [target for target in context.targets if target in self._target_type_to_wrapper_class_map] if len(possible_wrappers) == 0: diff --git a/src/cli/argparser.py b/src/cli/argparser.py index 2d99a823c..07acedf98 100644 --- a/src/cli/argparser.py +++ b/src/cli/argparser.py @@ -296,8 +296,10 @@ class ArgParser(object): new_value = safe_eval(new_value) config.set(setting_name, new_value) print >> sys.stderr, " New Gramps config " \ - "setting: %s:%s" % (setting_name, \ - repr(config.get(setting_name))) + "setting: %s:%s" % ( + setting_name, + repr(config.get(setting_name)) + ) else: need_to_quit = True else: diff --git a/src/gui/editors/editchildref.py b/src/gui/editors/editchildref.py index c23e36c86..79d352ef1 100644 --- a/src/gui/editors/editchildref.py +++ b/src/gui/editors/editchildref.py @@ -144,7 +144,8 @@ class EditChildRef(EditSecondary): """ notebook = gtk.Notebook() - self.srcref_list = SourceEmbedList(self.dbstate,self.uistate,self.track,self.obj) + self.srcref_list = SourceEmbedList( + self.dbstate, self.uistate, self.track, self.obj) self._add_tab(notebook, self.srcref_list) self.track_ref_for_deletion("srcref_list") @@ -201,9 +202,9 @@ class EditChildRef(EditSecondary): self.close() def button_activated(event, mouse_button): - if (event.type == gtk.gdk.BUTTON_PRESS and \ + if (event.type == gtk.gdk.BUTTON_PRESS and event.button == mouse_button) or \ - (event.type == gtk.gdk.KEY_PRESS and \ + (event.type == gtk.gdk.KEY_PRESS and event.keyval in (_RETURN, _KP_ENTER)): return True else: diff --git a/src/gui/editors/editevent.py b/src/gui/editors/editevent.py index 3f5d1e6a5..80f45b577 100644 --- a/src/gui/editors/editevent.py +++ b/src/gui/editors/editevent.py @@ -99,8 +99,9 @@ class EditEvent(EditPrimary): return dialog_title def get_custom_events(self): - return self.dbstate.db.get_person_event_types() + \ - self.dbstate.db.get_family_event_types() + return (self.dbstate.db.get_person_event_types() + + self.dbstate.db.get_family_event_types() + ) def _local_init(self): self.width_key = 'interface.event-width' diff --git a/src/gui/editors/editeventref.py b/src/gui/editors/editeventref.py index 736c39dd7..50d4e3317 100644 --- a/src/gui/editors/editeventref.py +++ b/src/gui/editors/editeventref.py @@ -263,5 +263,5 @@ class EditFamilyEventRef(EditEventRef): self.add_event = self.db.add_family_event def get_custom_events(self): - return [ gen.lib.EventType((gen.lib.EventType.CUSTOM,val)) \ + return [gen.lib.EventType((gen.lib.EventType.CUSTOM,val)) for val in self.dbstate.db.get_family_event_types()] diff --git a/src/gui/editors/editfamily.py b/src/gui/editors/editfamily.py index 778708c84..fac592af1 100644 --- a/src/gui/editors/editfamily.py +++ b/src/gui/editors/editfamily.py @@ -240,9 +240,9 @@ class ChildEmbedList(EmbeddedList): def share_button_clicked(self, obj=None): # it only makes sense to skip those who are already in the family - skip_list = [self.family.get_father_handle(), \ - self.family.get_mother_handle()] + \ - [x.ref for x in self.family.get_child_ref_list() ] + skip_list = [self.family.get_father_handle(), + self.family.get_mother_handle()] + skip_list.extend(x.ref for x in self.family.get_child_ref_list()) sel = SelectPerson(self.dbstate, self.uistate, self.track, _("Select Child"), skip=skip_list) @@ -432,9 +432,11 @@ class EditFamily(EditPrimary): # look for the scenerio of a child and no parents on a new # family - if self.added and self.obj.get_father_handle() is None and \ - self.obj.get_mother_handle() is None and \ - len(self.obj.get_child_ref_list()) == 1: + if (self.added and + not self.obj.get_father_handle() and + not self.obj.get_mother_handle() and + len(self.obj.get_child_ref_list()) == 1): + self.add_parent = True if not config.get('preferences.family-warn'): for i in self.hidden: @@ -689,8 +691,8 @@ class EditFamily(EditPrimary): mhandle = self.obj.get_mother_handle() self.update_mother(mhandle) - self.phandles = [mhandle, fhandle] + \ - [ x.ref for x in self.obj.get_child_ref_list()] + self.phandles = [mhandle, fhandle] + self.phandles.extend(x.ref for x in self.obj.get_child_ref_list()) self.phandles = filter(None, self.phandles) @@ -988,9 +990,10 @@ class EditFamily(EditPrimary): self.db.commit_person(person, trans) def object_is_empty(self): - return self.obj.get_father_handle() is None and \ - self.obj.get_mother_handle() is None and \ - len(self.obj.get_child_ref_list()) == 0 + return (not self.obj.get_father_handle() and + not self.obj.get_mother_handle() and + len(self.obj.get_child_ref_list()) == 0 + ) def save(self, *obj): try: @@ -1173,9 +1176,9 @@ class EditFamily(EditPrimary): return name def button_activated(event, mouse_button): - if (event.type == gtk.gdk.BUTTON_PRESS and \ + if (event.type == gtk.gdk.BUTTON_PRESS and event.button == mouse_button) or \ - (event.type == gtk.gdk.KEY_PRESS and \ + (event.type == gtk.gdk.KEY_PRESS and event.keyval in (_RETURN, _KP_ENTER)): return True else: diff --git a/src/gui/editors/editmedia.py b/src/gui/editors/editmedia.py index 49d06cea1..489fff53e 100644 --- a/src/gui/editors/editmedia.py +++ b/src/gui/editors/editmedia.py @@ -344,36 +344,36 @@ class DeleteMediaQuery(object): for handle in person_list: person = self.db.get_person_from_handle(handle) - new_list = [ photo for photo in person.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] + new_list = [photo for photo in person.get_media_list() + if photo.get_reference_handle() != self.media_handle] person.set_media_list(new_list) self.db.commit_person(person, trans) for handle in family_list: family = self.db.get_family_from_handle(handle) - new_list = [ photo for photo in family.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] + new_list = [photo for photo in family.get_media_list() + if photo.get_reference_handle() != self.media_handle] family.set_media_list(new_list) self.db.commit_family(family, trans) for handle in event_list: event = self.db.get_event_from_handle(handle) - new_list = [ photo for photo in event.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] + new_list = [photo for photo in event.get_media_list() + if photo.get_reference_handle() != self.media_handle] event.set_media_list(new_list) self.db.commit_event(event, trans) for handle in place_list: place = self.db.get_place_from_handle(handle) - new_list = [ photo for photo in place.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] + new_list = [photo for photo in place.get_media_list() + if photo.get_reference_handle() != self.media_handle] place.set_media_list(new_list) self.db.commit_place(place, trans) for handle in source_list: source = self.db.get_source_from_handle(handle) - new_list = [ photo for photo in source.get_media_list() \ - if photo.get_reference_handle() != self.media_handle ] + new_list = [photo for photo in source.get_media_list() + if photo.get_reference_handle() != self.media_handle] source.set_media_list(new_list) self.db.commit_source(source, trans) diff --git a/src/gui/editors/editperson.py b/src/gui/editors/editperson.py index 833a17dc3..5baec5372 100644 --- a/src/gui/editors/editperson.py +++ b/src/gui/editors/editperson.py @@ -685,11 +685,11 @@ class EditPerson(EditPrimary): """ Override base class, make inactive home action if not needed. """ - if self.dbstate.db.get_default_person() and \ - self.obj.get_handle() == \ - self.dbstate.db.get_default_person().get_handle(): + if (self.dbstate.db.get_default_person() and + self.obj.get_handle() == + self.dbstate.db.get_default_person().get_handle()): self.home_action.set_sensitive(False) - else : + else: self.home_action.set_sensitive(True) def _make_active(self, obj): diff --git a/src/images/mk_blue_marble.py b/src/images/mk_blue_marble.py index 9d42ee796..e4ca5785a 100644 --- a/src/images/mk_blue_marble.py +++ b/src/images/mk_blue_marble.py @@ -41,7 +41,7 @@ def process_file( imagefile, image_width, image_height, map_x, map_y, map_width, tile_x = map_x + tile_width * x tile_y = map_y - tile_width * y print "location: %dx%d" % (tile_x,tile_y) - tile_defines.append("self.zoom_map.add_map_source('%s', %d,%d, %d,%d, %d,%d)" %\ + tile_defines.append("self.zoom_map.add_map_source('%s', %d,%d, %d,%d, %d,%d)" % (outfile,tile_x,tile_y,tile_width,tile_width,tile_size,tile_size)) x = x + 1 y = y + 1 diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index d9cc31f6f..9f00b90d7 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -134,7 +134,7 @@ class WebCalReport(Report): self.anniv = mgobn('anniversaries') self.home_link = mgobn('home_link') - self.month_notes = [mgobn('note_' + month) \ + self.month_notes = [mgobn('note_' + month) for month in ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']] diff --git a/src/test/regrtest.py b/src/test/regrtest.py index b11735578..08622fc72 100755 --- a/src/test/regrtest.py +++ b/src/test/regrtest.py @@ -77,8 +77,8 @@ def getTestSuites(loc=gramps_root): test_suites = [] perf_suites = [] # note that test_mod and match_mod modify passed-in lists - paths = [(path,files) for path,dirs,files in os.walk(loc) \ - if test_mod(path,dirs) and match_mod(files)] + paths = [(path,files) for path,dirs,files in os.walk(loc) + if test_mod(path,dirs) and match_mod(files)] ## NO -- see explanation below ## oldpath = list(sys.path) diff --git a/src/web/libdjango.py b/src/web/libdjango.py index 7ae1473da..a14e1d2a1 100644 --- a/src/web/libdjango.py +++ b/src/web/libdjango.py @@ -203,26 +203,26 @@ class DjangoInterface(object): def get_child_ref_list(self, family): obj_type = ContentType.objects.get_for_model(family) - childrefs = models.ChildRef.objects.filter(object_id=family.id, \ - object_type=obj_type).order_by("order") + childrefs = models.ChildRef.objects.filter(object_id=family.id, + object_type=obj_type).order_by("order") return map(self.pack_child_ref, childrefs) def get_source_ref_list(self, obj): obj_type = ContentType.objects.get_for_model(obj) - sourcerefs = models.SourceRef.objects.filter(object_id=obj.id, \ - object_type=obj_type).order_by("order") + sourcerefs = models.SourceRef.objects.filter(object_id=obj.id, + object_type=obj_type).order_by("order") return map(self.pack_source_ref, sourcerefs) def get_event_refs(self, obj, order="order"): obj_type = ContentType.objects.get_for_model(obj) - eventrefs = models.EventRef.objects.filter(object_id=obj.id, \ - object_type=obj_type).order_by(order) + eventrefs = models.EventRef.objects.filter(object_id=obj.id, + object_type=obj_type).order_by(order) return eventrefs def get_event_ref_list(self, obj): obj_type = ContentType.objects.get_for_model(obj) - eventrefs = models.EventRef.objects.filter(object_id=obj.id, \ - object_type=obj_type).order_by("order") + eventrefs = models.EventRef.objects.filter(object_id=obj.id, + object_type=obj_type).order_by("order") return map(self.pack_event_ref, eventrefs) def get_family_list(self, person): # person has families diff --git a/src/web/sortheaders.py b/src/web/sortheaders.py index 25ee58d9a..011c24d37 100644 --- a/src/web/sortheaders.py +++ b/src/web/sortheaders.py @@ -115,7 +115,7 @@ class SortHeaders: always be present. """ params.update(self.additional_params) - return '?%s' % '&'.join(['%s=%s' % (param, value) \ + return '?%s' % '&'.join(['%s=%s' % (param, value) for param, value in params.items()]) def get_order_by(self):