From 498229277495783ce6e4d9d5091fefd2c42fc09c Mon Sep 17 00:00:00 2001 From: Gerald Britton Date: Mon, 16 Jun 2008 15:01:46 +0000 Subject: [PATCH] Code optimizations wrt handling of None - bug 2212 svn: r10811 --- src/AutoComp.py | 4 +- src/BaseDoc.py | 40 +++++++------- src/BasicUtils/_NameDisplay.py | 8 +-- src/Config/_GrampsGconfKeys.py | 16 +++--- src/Config/_GrampsIniKeys.py | 2 +- src/DataViews/GrampletView.py | 28 +++++----- src/DataViews/PedigreeView.py | 8 +-- src/DataViews/PersonView.py | 4 +- src/DataViews/RelationView.py | 4 +- src/DateHandler/_DateDisplay.py | 6 +-- src/DateHandler/_DateParser.py | 18 +++---- src/DateHandler/_Date_de.py | 2 +- src/DateHandler/_Date_fi.py | 2 +- src/DateHandler/_Date_fr.py | 2 +- src/DateHandler/_Date_nl.py | 2 +- src/DateHandler/_Date_pl.py | 2 +- src/DbManager.py | 2 +- src/DisplayModels/_BaseModel.py | 10 ++-- src/DisplayModels/_PeopleModel.py | 8 +-- src/DisplayState.py | 4 +- src/DisplayTabs/_ButtonTab.py | 2 +- src/DisplayTabs/_EmbeddedList.py | 2 +- src/DisplayTabs/_GalleryTab.py | 2 +- src/Editors/_EditFamily.py | 14 ++--- src/Editors/_EditMediaRef.py | 24 ++++----- src/Editors/_EditPerson.py | 12 ++--- src/FilterEditor/_EditRule.py | 2 +- src/Filters/Rules/Note/_MatchesRegexpOf.py | 2 +- .../Rules/Person/_RelationshipPathBetween.py | 4 +- .../_RelationshipPathBetweenBookmarks.py | 6 +-- .../Rules/Place/_InLatLonNeighborhood.py | 14 ++--- src/Filters/Rules/_HasNoteRegexBase.py | 2 +- src/Filters/Rules/_RegExpIdBase.py | 2 +- src/Filters/Rules/_Rule.py | 2 +- src/Filters/_FilterParser.py | 2 +- src/Filters/_GenericFilter.py | 4 +- src/GrampsCfg.py | 4 +- src/GrampsDbUtils/_GedcomParse.py | 8 +-- src/GrampsDbUtils/_GrampsBSDDB.py | 24 ++++----- src/GrampsDbUtils/_GrampsDbWriteXML.py | 18 +++---- src/GrampsDbUtils/_ReadXML.py | 14 ++--- src/GrampsDbUtils/_WriteGedcom.py | 4 +- src/GrampsDbUtils/_WriteGrdb.py | 2 +- src/LdsUtils.py | 6 +-- src/ListModel.py | 2 +- src/Lru.py | 4 +- src/ManagedWindow.py | 2 +- src/Merge/_MergePerson.py | 2 +- src/PageView.py | 2 +- src/PlaceUtils.py | 10 ++-- src/PluginUtils/_GuiOptions.py | 2 +- src/PluginUtils/_PluginMgr.py | 1 - src/PluginUtils/_PluginWindows.py | 2 +- src/Relationship.py | 12 ++--- src/ReportBase/_Bibliography.py | 4 +- src/ReportBase/_DocReportDialog.py | 2 +- src/ReportBase/_Endnotes.py | 2 +- src/ReportBase/_GraphvizReportDialog.py | 2 +- src/ReportBase/_ReportUtils.py | 16 +++--- src/ScratchPad.py | 2 +- src/Simple/_SimpleAccess.py | 2 +- src/Simple/_SimpleTable.py | 22 ++++---- src/ThumbNails.py | 4 +- src/TreeTips.py | 2 +- src/Utils.py | 4 +- src/ViewManager.py | 4 +- src/data/authors.xml | 3 ++ src/docgen/HtmlDoc.py | 8 +-- src/docgen/LaTeXDoc.py | 8 +-- src/docgen/ODFDoc.py | 2 +- src/docgen/PSDrawDoc.py | 4 +- src/gen/db/base.py | 22 ++++---- src/gen/db/dbdir.py | 10 ++-- src/gen/lib/date.py | 18 +++---- src/gen/lib/datebase.py | 2 +- src/gen/lib/event.py | 3 +- src/gen/lib/eventref.py | 1 + src/gen/lib/familyreltype.py | 2 +- src/gen/lib/genderstats.py | 2 +- src/gen/lib/place.py | 2 +- src/gen/lib/test/date_test.py | 2 +- src/gen/proxy/living.py | 2 +- src/gen/utils/callback.py | 6 +-- src/gen/utils/dbutils.py | 8 +-- src/gen/utils/progressmon.py | 6 +-- src/plugins/AgeOnDate.py | 6 +-- src/plugins/Calendar.py | 12 ++--- src/plugins/ChangeNames.py | 4 +- src/plugins/Check.py | 2 +- src/plugins/DefaultGramplets.py | 4 +- src/plugins/DetAncestralReport.py | 2 +- src/plugins/ExportCSV.py | 2 +- src/plugins/ExportVCalendar.py | 2 +- src/plugins/ExportVCard.py | 2 +- src/plugins/FamilyGroup.py | 8 +-- src/plugins/GVFamilyLines.py | 8 +-- src/plugins/ImportCSV.py | 54 +++++++++---------- src/plugins/ImportGeneWeb.py | 10 ++-- src/plugins/ImportvCard.py | 2 +- src/plugins/IndivComplete.py | 2 +- src/plugins/MediaManager.py | 2 +- src/plugins/NarrativeWeb.py | 6 +-- src/plugins/Query.py | 2 +- src/plugins/RelCalc.py | 2 +- src/plugins/ReorderIds.py | 2 +- src/plugins/TestcaseGenerator.py | 2 +- src/plugins/TimeLine.py | 4 +- src/plugins/WebCal.py | 10 ++-- src/plugins/WriteFtree.py | 2 +- src/plugins/WriteGeneWeb.py | 2 +- src/plugins/all_relations.py | 2 +- src/plugins/rel_cs.py | 4 +- src/plugins/rel_da.py | 2 +- src/plugins/rel_es.py | 4 +- src/plugins/rel_fi.py | 2 +- src/plugins/rel_hu.py | 2 +- src/plugins/rel_it.py | 2 +- src/plugins/rel_no.py | 2 +- src/plugins/rel_pl.py | 4 +- src/plugins/rel_pt.py | 4 +- src/plugins/rel_ru.py | 2 +- src/plugins/rel_sk.py | 4 +- src/widgets/labels.py | 2 +- src/widgets/monitoredwidgets.py | 2 +- 124 files changed, 379 insertions(+), 377 deletions(-) diff --git a/src/AutoComp.py b/src/AutoComp.py index d3c5974eb..3207794ed 100644 --- a/src/AutoComp.py +++ b/src/AutoComp.py @@ -141,7 +141,7 @@ class StandardCustomSelector: self.selector.set_text_column(1) else: self.selector = gtk.ComboBoxEntry(self.store, 1) - if self.active_key != None: + if self.active_key is not None: self.selector.set_active(self.active_index) # make autocompletion work @@ -222,7 +222,7 @@ class StandardCustomSelector: key, text = val if key in self.mapping.keys() and key != self.custom_key: self.store.foreach(self.set_int_value, key) - elif self.custom_key != None: + elif self.custom_key is not None: self.selector.child.set_text(text) else: print "StandardCustomSelector.set(): Option not available:", val diff --git a/src/BaseDoc.py b/src/BaseDoc.py index 30db052b5..2c455747d 100644 --- a/src/BaseDoc.py +++ b/src/BaseDoc.py @@ -347,17 +347,17 @@ class FontStyle: in the range of 0-255 represeting the red, green, and blue components of a color. """ - if face != None: + if face is not None: self.set_type_face(face) - if size != None: + if size is not None: self.set_size(size) - if italic != None: + if italic is not None: self.set_italic(italic) - if bold != None: + if bold is not None: self.set_bold(bold) - if underline != None: + if underline is not None: self.set_underline(underline) - if color != None: + if color is not None: self.set_color(color) def set_italic(self, val): @@ -671,31 +671,31 @@ class ParagraphStyle: @param bgcolor: background color of the paragraph as an RGB tuple. @param font: FontStyle instance that defines the font """ - if font != None: + if font is not None: self.font = FontStyle(font) - if pad != None: + if pad is not None: self.set_padding(pad) - if tborder != None: + if tborder is not None: self.set_top_border(tborder) - if bborder != None: + if bborder is not None: self.set_bottom_border(bborder) - if rborder != None: + if rborder is not None: self.set_right_border(rborder) - if lborder != None: + if lborder is not None: self.set_left_border(lborder) - if bgcolor != None: + if bgcolor is not None: self.set_background_color(bgcolor) - if align != None: + if align is not None: self.set_alignment(align) - if rmargin != None: + if rmargin is not None: self.set_right_margin(rmargin) - if lmargin != None: + if lmargin is not None: self.set_left_margin(lmargin) - if first_indent != None: + if first_indent is not None: self.set_first_indent(first_indent) - if tmargin != None: + if tmargin is not None: self.set_top_margin(tmargin) - if bmargin != None: + if bmargin is not None: self.set_bottom_margin(bmargin) def set_header_level(self, level): @@ -1028,7 +1028,7 @@ class StyleSheet: self.table_styles = {} self.cell_styles = {} self.name = "" - if obj != None: + if obj is not None: for style_name in obj.para_styles.keys(): style = obj.para_styles[style_name] self.para_styles[style_name] = ParagraphStyle(style) diff --git a/src/BasicUtils/_NameDisplay.py b/src/BasicUtils/_NameDisplay.py index b59e93e7b..2ab20597d 100644 --- a/src/BasicUtils/_NameDisplay.py +++ b/src/BasicUtils/_NameDisplay.py @@ -166,7 +166,7 @@ class NameDisplay: for (num, name,fmt_str,act) in formats: func = self._format_fn(fmt_str) func_raw = raw_func_dict.get(num) - if func_raw == None: + if func_raw is None: func_raw = self._format_raw_fn(fmt_str) self.name_formats[num] = (name,fmt_str,act,func,func_raw) @@ -427,7 +427,7 @@ def fn(%s): method call and we need all the speed we can squeeze out of this. """ func = self.__class__.raw_format_funcs.get(format_str) - if func == None: + if func is None: func = self._gen_raw_func(format_str) self.__class__.raw_format_funcs[format_str] = func @@ -455,7 +455,7 @@ def fn(%s): All the other characters in the fmt_str are unaffected. """ func = self.__class__.format_funcs.get(format_str) - if func == None: + if func is None: func = self._gen_cooked_func(format_str) self.__class__.format_funcs[format_str] = func try: @@ -555,7 +555,7 @@ def fn(%s): @returns: Returns the L{Name} string representation @rtype: str """ - if name == None: + if name is None: return "" num = self._is_format_valid(name.display_as) diff --git a/src/Config/_GrampsGconfKeys.py b/src/Config/_GrampsGconfKeys.py index 70470a1c0..4b544704c 100644 --- a/src/Config/_GrampsGconfKeys.py +++ b/src/Config/_GrampsGconfKeys.py @@ -101,20 +101,20 @@ def get(key): val = get_string(token) except: val = default_value[key] - if val == None: + if val is None: val = default_value[key] return val def get_bool(key): val = client.get(key) - if val == None: + if val is None: return None val = client.get_bool(key) if val in (True, False): return val else: val = client.get_default_from_schema(key) - if val == None: + if val is None: raise Errors.GConfSchemaError("No default value for key "+key) return val.get_bool() @@ -124,14 +124,14 @@ def set_bool(key, val): def get_int(key, correct_tuple=None): val = client.get(key) - if val == None: + if val is None: return None val = client.get_int(key) if not correct_tuple or val in correct_tuple: return val else: val = client.get_default_from_schema(key) - if val == None: + if val is None: raise Errors.GConfSchemaError("No default value for key "+key) return val.get_int() @@ -141,14 +141,14 @@ def set_int(key, val, correct_tuple=None): def get_string(key, test_func=None): val = client.get(key) - if val == None: + if val is None: return None val = client.get_string(key) if not test_func or test_func(val): return val else: val = client.get_default_from_schema(key) - if val == None: + if val is None: raise Errors.GConfSchemaError("No default value for key "+key) return val.get_string() @@ -162,7 +162,7 @@ def sync(): def get_default(key, sample=''): token = "/apps/gramps/%s/%s" % (key[0], key[1]) value = client.get_default_from_schema(token) - if value == None: + if value is None: raise Errors.GConfSchemaError("No default value for key "+key[1]) if isinstance(sample, basestring): return value.get_string() diff --git a/src/Config/_GrampsIniKeys.py b/src/Config/_GrampsIniKeys.py index e46647f34..340b4e973 100644 --- a/src/Config/_GrampsIniKeys.py +++ b/src/Config/_GrampsIniKeys.py @@ -209,7 +209,7 @@ def get(key): val = get_int(key) else: val = get_string(key) - if val == None or val == "": + if val is None or val == "": val = default_value[key] return val diff --git a/src/DataViews/GrampletView.py b/src/DataViews/GrampletView.py index f3fdfeffb..09e1a722a 100644 --- a/src/DataViews/GrampletView.py +++ b/src/DataViews/GrampletView.py @@ -136,7 +136,7 @@ def make_requested_gramplet(viewpage, name, opts, dbstate, uistate): msg = None if gui.pui: msg = gui.pui.tooltip - if msg == None: + if msg is None: msg = _("Drag Properties Button to move and click it for setup") if msg: gui.tooltips = gtk.Tooltips() @@ -415,7 +415,7 @@ class Gramplet(object): if iter.has_tag(tag): if link_type == 'Person': person = self.dbstate.db.get_person_from_handle(handle) - if person != None: + if person is not None: if event.button == 1: # left mouse if event.type == gtk.gdk._2BUTTON_PRESS: # double try: @@ -726,7 +726,7 @@ class MyScrolledWindow(gtk.ScrolledWindow): # Hack to get around show_all that shows hidden items # do once, the first time showing if self.viewpage: - gramplets = [g for g in self.viewpage.gramplet_map.values() if g != None] + gramplets = [g for g in self.viewpage.gramplet_map.values() if g is not None] self.viewpage = None for gramplet in gramplets: gramplet.gvoptions.hide() @@ -820,7 +820,7 @@ class GrampletView(PageView.PersonNavView): """ Detach all of the mainframe gramplets from the columns. """ - gramplets = [g for g in self.gramplet_map.values() if g != None] + gramplets = [g for g in self.gramplet_map.values() if g is not None] for gramplet in gramplets: if (gramplet.state == "windowed" or gramplet.state == "closed"): continue @@ -832,7 +832,7 @@ class GrampletView(PageView.PersonNavView): """ Place the gramplet mainframes in the columns. """ - gramplets = [g for g in self.gramplet_map.values() if g != None] + gramplets = [g for g in self.gramplet_map.values() if g is not None] # put the gramplets where they go: # sort by row gramplets.sort(lambda a, b: cmp(a.row, b.row)) @@ -913,7 +913,7 @@ class GrampletView(PageView.PersonNavView): for gframe in self.columns[col]: gramplet = self.frame_map[str(gframe)] opts = get_gramplet_options_by_name(gramplet.name) - if opts != None: + if opts is not None: base_opts = opts.copy() for key in base_opts: if key in gramplet.__dict__: @@ -940,7 +940,7 @@ class GrampletView(PageView.PersonNavView): row += 1 for gramplet in self.detached_gramplets: opts = get_gramplet_options_by_name(gramplet.name) - if opts != None: + if opts is not None: base_opts = opts.copy() for key in base_opts: if key in gramplet.__dict__: @@ -1093,7 +1093,7 @@ class GrampletView(PageView.PersonNavView): if gramplet.title == name: #gramplet.state = "maximized" self.closed_gramplets.remove(gramplet) - if self._popup_xy != None: + if self._popup_xy is not None: self.drop_widget(self.widget, gramplet, self._popup_xy[0], self._popup_xy[1], 0) else: @@ -1122,7 +1122,7 @@ class GrampletView(PageView.PersonNavView): # set height on gramplet.scrolledwindow here: gramplet.scrolledwindow.set_size_request(-1, gramplet.height) ## now drop it in right place - if self._popup_xy != None: + if self._popup_xy is not None: self.drop_widget(self.widget, gramplet, self._popup_xy[0], self._popup_xy[1], 0) else: @@ -1132,7 +1132,7 @@ class GrampletView(PageView.PersonNavView): tname = obj.get_child().get_label() all_opts = get_gramplet_options_by_tname(tname) name = all_opts["name"] - if all_opts == None: + if all_opts is None: print "Unknown gramplet type: '%s'; bad gramplets.ini file?" % name return if "title" not in all_opts: @@ -1159,7 +1159,7 @@ class GrampletView(PageView.PersonNavView): # set height on gramplet.scrolledwindow here: gramplet.scrolledwindow.set_size_request(-1, gramplet.height) ## now drop it in right place - if self._popup_xy != None: + if self._popup_xy is not None: self.drop_widget(self.widget, gramplet, self._popup_xy[0], self._popup_xy[1], 0) else: @@ -1223,7 +1223,7 @@ class GrampletView(PageView.PersonNavView): ag_menu = self.uistate.uimanager.get_widget('/Popup/AddGramplet') if ag_menu: qr_menu = ag_menu.get_submenu() - if qr_menu == None: + if qr_menu is None: qr_menu = gtk.Menu() names = [AVAILABLE_GRAMPLETS[key]["tname"] for key in AVAILABLE_GRAMPLETS.keys()] @@ -1235,7 +1235,7 @@ class GrampletView(PageView.PersonNavView): rg_menu = self.uistate.uimanager.get_widget('/Popup/RestoreGramplet') if rg_menu: qr_menu = rg_menu.get_submenu() - if qr_menu != None: + if qr_menu is not None: rg_menu.remove_submenu() names = [] for gramplet in self.closed_gramplets: @@ -1255,7 +1255,7 @@ class GrampletView(PageView.PersonNavView): return False def on_delete(self): - gramplets = [g for g in self.gramplet_map.values() if g != None] + gramplets = [g for g in self.gramplet_map.values() if g is not None] for gramplet in gramplets: # this is the only place where the gui runs user code directly if gramplet.pui: diff --git a/src/DataViews/PedigreeView.py b/src/DataViews/PedigreeView.py index 15d3bbd32..c510f3f0c 100644 --- a/src/DataViews/PedigreeView.py +++ b/src/DataViews/PedigreeView.py @@ -1255,7 +1255,7 @@ class PedigreeView(PageView.PersonNavView): def find_tree(self,person,index,depth,lst,val=0): """Recursively build a list of ancestors""" - if depth > 5 or person == None: + if depth > 5 or person is None: return try: @@ -1276,7 +1276,7 @@ class PedigreeView(PageView.PersonNavView): mrel = True frel = True family = self.dbstate.db.get_family_from_handle(family_handle) - if family != None: + if family is not None: for child_ref in family.get_child_ref_list(): if child_ref.ref == person.handle: mrel = child_ref.mrel == gen.lib.ChildRefType.BIRTH @@ -1284,11 +1284,11 @@ class PedigreeView(PageView.PersonNavView): lst[index] = (person,val,family,alive) father_handle = family.get_father_handle() - if father_handle != None: + if father_handle is not None: father = self.dbstate.db.get_person_from_handle(father_handle) self.find_tree(father,(2*index)+1,depth+1,lst,frel) mother_handle = family.get_mother_handle() - if mother_handle != None: + if mother_handle is not None: mother = self.dbstate.db.get_person_from_handle(mother_handle) self.find_tree(mother,(2*index)+2,depth+1,lst,mrel) diff --git a/src/DataViews/PersonView.py b/src/DataViews/PersonView.py index f7c3a1942..eef8d4764 100644 --- a/src/DataViews/PersonView.py +++ b/src/DataViews/PersonView.py @@ -527,7 +527,7 @@ class PersonView(PageView.PersonNavView): active = self.dbstate.active self.tree.set_model(self.model) - if const.USE_TIPS and self.model.tooltip_column != None: + if const.USE_TIPS and self.model.tooltip_column is not None: self.tooltips = TreeTips.TreeTips(self.tree, self.model.tooltip_column, True) @@ -984,7 +984,7 @@ class PersonView(PageView.PersonNavView): node = self.model.on_get_iter(path) # Node might be null if the surname is not known so test against None - while node != None: + while node is not None: real_iter = self.model.get_iter(path) for subindex in range(0, self.model.iter_n_children(real_iter)): subpath = ((path[0], subindex)) diff --git a/src/DataViews/RelationView.py b/src/DataViews/RelationView.py index 4bada127a..677a27ec1 100644 --- a/src/DataViews/RelationView.py +++ b/src/DataViews/RelationView.py @@ -662,7 +662,7 @@ class RelationshipView(PageView.PersonNavView): hbox = gtk.HBox() label = widgets.MarkupLabel(msg, x_align=1) # Draw the collapse/expand button: - if family != None: + if family is not None: if self.check_collapsed(person.handle, family.handle): arrow = widgets.ExpandCollapseArrow(True, self.expand_collapse_press, @@ -1189,7 +1189,7 @@ class RelationshipView(PageView.PersonNavView): def write_family(self, family_handle, person = None): family = self.dbstate.db.get_family_from_handle(family_handle) - if family == None: + if family is None: from QuestionDialog import WarningDialog WarningDialog( _('Broken family detected'), diff --git a/src/DateHandler/_DateDisplay.py b/src/DateHandler/_DateDisplay.py index c2e3d9b24..0150ef430 100644 --- a/src/DateHandler/_DateDisplay.py +++ b/src/DateHandler/_DateDisplay.py @@ -112,7 +112,7 @@ class DateDisplay: ] self.verify_format(format) - if format == None: + if format is None: self.format = 0 else: self.format = format @@ -177,7 +177,7 @@ class DateDisplay: # YYYY-MM-DD (ISO) year = self._slash_year(date_val[2], date_val[3]) # This produces 1789, 1789-00-11 and 1789-11-00 for incomplete dates. - if date_val[0] == 0 and date_val[1] == 0: + if date_val[0] == date_val[1] == 0: # No month and no day -> year value = year else: @@ -203,7 +203,7 @@ class DateDisplay: if date_val[3]: return self.display_iso(date_val) else: - if date_val[0] == 0 and date_val[1] == 0: + if date_val[0] == date_val[1] == 0: value = str(date_val[2]) else: value = self._tformat.replace('%m', str(date_val[1])) diff --git a/src/DateHandler/_DateParser.py b/src/DateHandler/_DateParser.py index 7b547d326..f28e810c7 100644 --- a/src/DateHandler/_DateParser.py +++ b/src/DateHandler/_DateParser.py @@ -288,7 +288,7 @@ class DateParser: Convert the string to an integer if the value is not None. If the value is None, a zero is returned """ - if val == None: + if val is None: return 0 else: return int(val) @@ -317,18 +317,18 @@ class DateParser: match = regex1.match(text.lower()) if match: groups = match.groups() - if groups[0] == None: + if groups[0] is None: m = 0 else: m = mmap[groups[0].lower()] - if groups[2] == None: + if groups[2] is None: y = self._get_int(groups[1]) d = 0 s = False else: d = self._get_int(groups[1]) - if groups[4] != None: # slash year "/80" + if groups[4] is not None: # slash year "/80" y = int(groups[3]) + 1 # fullyear + 1 s = True else: # regular, non-slash date @@ -342,18 +342,18 @@ class DateParser: match = regex2.match(text.lower()) if match: groups = match.groups() - if groups[1] == None: + if groups[1] is None: m = 0 else: m = mmap[groups[1].lower()] d = self._get_int(groups[0]) - if groups[2] == None: + if groups[2] is None: y = None s = False else: - if groups[4] != None: # slash year digit + if groups[4] is not None: # slash year digit y = int(groups[3]) + 1 # fullyear + 1 s = True else: @@ -370,7 +370,7 @@ class DateParser: """ Convert only the date portion of a date. """ - if subparser == None: + if subparser is None: subparser = self._parse_greg_julian if subparser == self._parse_greg_julian: @@ -411,7 +411,7 @@ class DateParser: groups = match.groups() if self.ymd: # '1789' and ymd: incomplete date - if groups[1] == None: + if groups[1] is None: y = self._get_int(groups[4]) m = 0 d = 0 diff --git a/src/DateHandler/_Date_de.py b/src/DateHandler/_Date_de.py index 05d650d86..a4dba4118 100644 --- a/src/DateHandler/_Date_de.py +++ b/src/DateHandler/_Date_de.py @@ -156,7 +156,7 @@ class DateDisplayDE(DateDisplay): if date_val[3]: return self.display_iso(date_val) else: - if date_val[0] == 0 and date_val[1] == 0: + if date_val[0] == date_val[1] == 0: value = str(date_val[2]) else: value = self._tformat.replace('%m', str(date_val[1])) diff --git a/src/DateHandler/_Date_fi.py b/src/DateHandler/_Date_fi.py index 9332d766f..f6a1a385b 100644 --- a/src/DateHandler/_Date_fi.py +++ b/src/DateHandler/_Date_fi.py @@ -151,7 +151,7 @@ class DateDisplayFI(DateDisplay): text = u"%s - %s" % (d1, d2) elif mod == Date.MOD_RANGE: stop = date.get_stop_date() - if start[0] == 0 and start[1] == 0 and stop[0] == 0 and stop[1] == 0: + if start[0] == start[1] == 0 and stop[0] == 0 and stop[1] == 0: d1 = self.display_cal[cal](start) d2 = self.display_cal[cal](stop) text = u"vuosien %s ja %s välillä" % (d1, d2) diff --git a/src/DateHandler/_Date_fr.py b/src/DateHandler/_Date_fr.py index 106b9cd7f..3269d3692 100644 --- a/src/DateHandler/_Date_fr.py +++ b/src/DateHandler/_Date_fr.py @@ -216,7 +216,7 @@ class DateDisplayFR(DateDisplay): if date_val[2] < 0 or date_val[3]: return self.display_iso(date_val) else: - if date_val[0] == 0 and date_val[1] == 0: + if date_val[0] == date_val[1] == 0: value = str(date_val[2]) else: value = self._tformat.replace('%m', str(date_val[1])) diff --git a/src/DateHandler/_Date_nl.py b/src/DateHandler/_Date_nl.py index ca460cb45..8e68e8678 100644 --- a/src/DateHandler/_Date_nl.py +++ b/src/DateHandler/_Date_nl.py @@ -159,7 +159,7 @@ class DateDisplayNL(DateDisplay): return self.display_iso(date_val) else: # Numeric - if date_val[0] == 0 and date_val[1] == 0: + if date_val[0] == date_val[1] == 0: value = str(date_val[2]) else: value = self._tformat.replace('%m', str(date_val[1])) diff --git a/src/DateHandler/_Date_pl.py b/src/DateHandler/_Date_pl.py index d2dd815f5..06635d701 100644 --- a/src/DateHandler/_Date_pl.py +++ b/src/DateHandler/_Date_pl.py @@ -175,7 +175,7 @@ class DateDisplayPL(DateDisplay): if date_val[3]: return self.display_iso(date_val) else: - if date_val[0] == 0 and date_val[1] == 0: + if date_val[0] == date_val[1] == 0: value = str(date_val[2]) else: value = self._tformat.replace('%m',str(date_val[0])) diff --git a/src/DbManager.py b/src/DbManager.py index 2e4b5015c..495ff3f55 100644 --- a/src/DbManager.py +++ b/src/DbManager.py @@ -245,7 +245,7 @@ class CLIDbManager: os.mkdir(new_path) path_name = os.path.join(new_path, NAME_FILE) - if title == None: + if title is None: name_list = [ name[0] for name in self.current_names ] title = find_next_db_name(name_list) diff --git a/src/DisplayModels/_BaseModel.py b/src/DisplayModels/_BaseModel.py index a2aba5854..f192fb520 100644 --- a/src/DisplayModels/_BaseModel.py +++ b/src/DisplayModels/_BaseModel.py @@ -271,7 +271,7 @@ class BaseModel(gtk.GenericTreeModel): self.node_map.set_path_map([ x[1] for x in self.sort_data ]) index = self.node_map.get_path(handle) - if index != None: + if index is not None: node = self.get_iter(index) self.row_inserted(index, node) @@ -332,23 +332,23 @@ class BaseModel(gtk.GenericTreeModel): def on_iter_children(self, node): """Return the first child of the node""" - if node == None and len(self.node_map): + if node is None and len(self.node_map): return self.node_map.get_first_handle() return None def on_iter_has_child(self, node): """returns true if this node has children""" - if node == None: + if node is None: return len(self.node_map) > 0 return False def on_iter_n_children(self, node): - if node == None: + if node is None: return len(self.node_map) return 0 def on_iter_nth_child(self, node, n): - if node == None: + if node is None: return self.node_map.get_handle(n) return None diff --git a/src/DisplayModels/_PeopleModel.py b/src/DisplayModels/_PeopleModel.py index 53ad3ce2a..91fe9e31d 100644 --- a/src/DisplayModels/_PeopleModel.py +++ b/src/DisplayModels/_PeopleModel.py @@ -159,20 +159,20 @@ class NodeTreeMap: return self.path2iter.get((surname, val+1)) def first_child(self, node): - if node == None: + if node is None: return self.top_path2iter[0] else: return self.path2iter.get((node, 0)) def has_child(self, node): - if node == None: + if node is None: return len(self.sname_sub) if self.sname_sub.has_key(node) and len(self.sname_sub[node]) > 0: return True return False def number_of_children(self, node): - if node == None: + if node is None: return len(self.sname_sub) try: return len(self.sname_sub[node]) @@ -181,7 +181,7 @@ class NodeTreeMap: def get_nth_child(self, node, n): try: - if node == None: + if node is None: return self.top_path2iter[n] try: return self.path2iter[(node, n)] diff --git a/src/DisplayState.py b/src/DisplayState.py index 04a5a16d0..a3fedfcc5 100644 --- a/src/DisplayState.py +++ b/src/DisplayState.py @@ -368,7 +368,7 @@ class DisplayState(gen.utils.Callback): self.relationship.connect_db_signals(dbstate) default_person = dbstate.db.get_default_person() active = dbstate.get_active_person() - if default_person == None or active == None: + if default_person is None or active is None: return u'' if default_person.handle == self.disprel_defpers and \ active.handle == self.disprel_active : @@ -428,7 +428,7 @@ class DisplayState(gen.utils.Callback): def modify_statusbar(self, dbstate, active=None): self.status.pop(self.status_id) - if dbstate.active == None: + if dbstate.active is None: self.status.push(self.status_id, "") else: person = dbstate.get_active_person() diff --git a/src/DisplayTabs/_ButtonTab.py b/src/DisplayTabs/_ButtonTab.py index 50bb18590..d7cc523f2 100644 --- a/src/DisplayTabs/_ButtonTab.py +++ b/src/DisplayTabs/_ButtonTab.py @@ -274,7 +274,7 @@ class ButtonTab(GrampsTab): # explicitly, dirty_selection must make sure they do not interact if self.dirty_selection: return - if self.get_selected() != None: + if self.get_selected() is not None: self.edit_btn.set_sensitive(True) if self.jump_btn: self.jump_btn.set_sensitive(True) diff --git a/src/DisplayTabs/_EmbeddedList.py b/src/DisplayTabs/_EmbeddedList.py index b4d137723..037168813 100644 --- a/src/DisplayTabs/_EmbeddedList.py +++ b/src/DisplayTabs/_EmbeddedList.py @@ -241,7 +241,7 @@ class EmbeddedList(ButtonTab): def _find_row(self, x, y): row = self.tree.get_path_at_pos(x, y) - if row == None: + if row is None: return len(self.get_data()) else: return row[0][0] diff --git a/src/DisplayTabs/_GalleryTab.py b/src/DisplayTabs/_GalleryTab.py index 504dc05ff..2cddc4860 100644 --- a/src/DisplayTabs/_GalleryTab.py +++ b/src/DisplayTabs/_GalleryTab.py @@ -203,7 +203,7 @@ class GalleryTab(ButtonTab): def _update_internal_list(self, *obj): newlist = [] node = self.iconmodel.get_iter_first() - while node != None: + while node is not None: newlist.append(self.iconmodel.get_value(node, 2)) node = self.iconmodel.iter_next(node) for i in xrange(len(self.media_list)): diff --git a/src/Editors/_EditFamily.py b/src/Editors/_EditFamily.py index 52aa9ea7b..849e8c927 100644 --- a/src/Editors/_EditFamily.py +++ b/src/Editors/_EditFamily.py @@ -141,7 +141,7 @@ class ChildEmbedList(EmbeddedList): def _find_row(self, x, y): row = self.tree.get_path_at_pos(x, y) - if row == None: + if row is None: return len(self.family.get_child_ref_list()) else: return row[0][0] @@ -415,8 +415,8 @@ 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() == None and \ - self.obj.get_mother_handle() == None and \ + 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: self.add_parent = True if not Config.get(Config.FAMILY_WARN): @@ -450,7 +450,7 @@ class EditFamily(EditPrimary): # Add a signal pick up changes to events, bug #1329 self._add_db_signal('event-update', self.event_updated) - self.added = self.obj.handle == None + self.added = self.obj.handle is None if self.added: self.obj.handle = Utils.create_id() @@ -802,7 +802,7 @@ class EditFamily(EditPrimary): def load_parent(self, handle, box, birth_obj, birth_label, death_obj, death_label, btn_obj, btn2_obj, add_msg, del_msg): - is_used = handle != None + is_used = handle is not None for i in box.get_children(): box.remove(i) @@ -872,8 +872,8 @@ class EditFamily(EditPrimary): self.db.commit_person(person, trans) def object_is_empty(self): - return self.obj.get_father_handle() == None and \ - self.obj.get_mother_handle() == None and \ + 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 def save(self, *obj): diff --git a/src/Editors/_EditMediaRef.py b/src/Editors/_EditMediaRef.py index 3b4ba796b..061e876f5 100644 --- a/src/Editors/_EditMediaRef.py +++ b/src/Editors/_EditMediaRef.py @@ -124,13 +124,13 @@ class EditMediaRef(EditReference): coord = self.source_ref.get_rectangle() #upgrade path: set invalid (from eg old db) to none - if coord is not None and ((coord[0] == None and coord[1] == None - and coord[2] == None and coord[3] == None) or ( - coord[0] == 0 and coord[1] == 0 - and coord[2] == 100 and coord[3] == 100) or ( - coord[0] == coord[2] and coord[1] == coord[3] - )): + if coord is not None and ( + (coord[0] is coord[1] is coord[2] is coord[3] is None) or \ + (coord[0] == coord[1] == 0 and coord[2] == coord[3] == 100) or \ + (coord[0] == coord[2] and coord[1] == coord[3]) + ): coord = None + self.rectangle = coord self.subpixmap = self.top.get_widget("subpixmap") @@ -474,13 +474,13 @@ class EditMediaRef(EditReference): self.top.get_widget("corner2_y").get_value_as_int(), ) #do not set unset or invalid coord - if (coord[0] == None and coord[1] == None - and coord[2] == None and coord[3] == None) or ( - coord[0] == 0 and coord[1] == 0 - and coord[2] == 100 and coord[3] == 100) or ( - coord[0] == coord[2] and coord[1] == coord[3] - ): + if coord is not None and ( + (coord[0] is coord[1] is coord[2] is coord[3] is None) or \ + (coord[0] == coord[1] == 0 and coord[2] == coord[3] == 100) or \ + (coord[0] == coord[2] and coord[1] == coord[3]) + ): coord = None + self.source_ref.set_rectangle(coord) #call callback if given diff --git a/src/Editors/_EditPerson.py b/src/Editors/_EditPerson.py index 8bb14b04d..6aa860e9d 100644 --- a/src/Editors/_EditPerson.py +++ b/src/Editors/_EditPerson.py @@ -571,7 +571,7 @@ class EditPerson(EditPrimary): """ self.load_obj = path self.load_rect = rectangle - if path == None: + if path is None: self.obj_photo.hide() else: try: @@ -579,7 +579,7 @@ class EditPerson(EditPrimary): width = i.get_width() height = i.get_height() - if rectangle != None: + if rectangle is not None: upper_x = min(rectangle[0], rectangle[2])/100. lower_x = max(rectangle[0], rectangle[2])/100. upper_y = min(rectangle[1], rectangle[3])/100. @@ -633,7 +633,7 @@ class EditPerson(EditPrimary): for tmp_handle in self.obj.get_family_handle_list(): temp_family = self.db.get_family_from_handle(tmp_handle) if self.obj == temp_family.get_mother_handle(): - if temp_family.get_father_handle() != None: + if temp_family.get_father_handle() is not None: error = True else: temp_family.set_mother_handle(None) @@ -642,7 +642,7 @@ class EditPerson(EditPrimary): for tmp_handle in self.obj.get_family_handle_list(): temp_family = self.db.get_family_from_handle(tmp_handle) if self.obj == temp_family.get_father_handle(): - if temp_family.get_mother_handle() != None: + if temp_family.get_mother_handle() is not None: error = True else: temp_family.set_father_handle(None) @@ -651,13 +651,13 @@ class EditPerson(EditPrimary): for tmp_handle in self.obj.get_family_handle_list(): temp_family = self.db.get_family_from_handle(tmp_handle) if self.obj == temp_family.get_father_handle(): - if temp_family.get_mother_handle() != None: + if temp_family.get_mother_handle() is not None: error = True else: temp_family.set_father_handle(None) temp_family.set_mother_handle(self.obj) if self.obj == temp_family.get_mother_handle(): - if temp_family.get_father_handle() != None: + if temp_family.get_father_handle() is not None: error = True else: temp_family.set_mother_handle(None) diff --git a/src/FilterEditor/_EditRule.py b/src/FilterEditor/_EditRule.py index 6bad90769..40e9836c3 100644 --- a/src/FilterEditor/_EditRule.py +++ b/src/FilterEditor/_EditRule.py @@ -307,7 +307,7 @@ class MyID(gtk.HBox): selector = selector_factory(obj_class) inst = selector(self.dbstate, self.uistate, self.track) val = inst.run() - if val == None: + if val is None: self.set_text('') else: self.set_text(val.get_gramps_id()) diff --git a/src/Filters/Rules/Note/_MatchesRegexpOf.py b/src/Filters/Rules/Note/_MatchesRegexpOf.py index 26d649e2c..63abb4780 100644 --- a/src/Filters/Rules/Note/_MatchesRegexpOf.py +++ b/src/Filters/Rules/Note/_MatchesRegexpOf.py @@ -58,6 +58,6 @@ class MatchesRegexpOf(Rule): def apply(self, db, note): """ Apply the filter """ text = unicode(note.get()) - if self.match.match(text) != None: + if self.match.match(text) is not None: return True return False diff --git a/src/Filters/Rules/Person/_RelationshipPathBetween.py b/src/Filters/Rules/Person/_RelationshipPathBetween.py index c6a970483..42219b1f3 100644 --- a/src/Filters/Rules/Person/_RelationshipPathBetween.py +++ b/src/Filters/Rules/Person/_RelationshipPathBetween.py @@ -77,14 +77,14 @@ class RelationshipPathBetween(Rule): def apply_filter(self,rank, handle,plist,pmap): person = self.db.get_person_from_handle(handle) - if person == None: + if person is None: return plist.append(handle) pmap[person.get_handle()] = rank fam_id = person.get_main_parents_family_handle() family = self.db.get_family_from_handle(fam_id) - if family != None: + if family is not None: self.apply_filter(rank+1,family.get_father_handle(),plist,pmap) self.apply_filter(rank+1,family.get_mother_handle(),plist,pmap) diff --git a/src/Filters/Rules/Person/_RelationshipPathBetweenBookmarks.py b/src/Filters/Rules/Person/_RelationshipPathBetweenBookmarks.py index 18dab01cd..4990dc4a2 100644 --- a/src/Filters/Rules/Person/_RelationshipPathBetweenBookmarks.py +++ b/src/Filters/Rules/Person/_RelationshipPathBetweenBookmarks.py @@ -78,7 +78,7 @@ class RelationshipPathBetweenBookmarks(Rule): person = self.db.get_person_from_handle(handle) except: return None - if person == None: + if person is None: return None try: name = person.get_primary_name().get_name() @@ -96,11 +96,11 @@ class RelationshipPathBetweenBookmarks(Rule): for handle in generation: try: person = self.db.get_person_from_handle(handle) - if person == None: + if person is None: continue fam_id = person.get_main_parents_family_handle() family = self.db.get_family_from_handle(fam_id) - if family == None: + if family is None: continue fhandle = family.get_father_handle() mhandle = family.get_mother_handle() diff --git a/src/Filters/Rules/Place/_InLatLonNeighborhood.py b/src/Filters/Rules/Place/_InLatLonNeighborhood.py index c1a597cf9..eccc0d451 100644 --- a/src/Filters/Rules/Place/_InLatLonNeighborhood.py +++ b/src/Filters/Rules/Place/_InLatLonNeighborhood.py @@ -59,7 +59,7 @@ class InLatLonNeighborhood(Rule): self.halfheight = float(self.list[2])/2. except ValueError : self.halfheight = None - if self.halfheight != None and self.halfheight<= 0. : + if self.halfheight is not None and self.halfheight<= 0. : self.halfheight = None else : self.halfheight = -1 @@ -71,7 +71,7 @@ class InLatLonNeighborhood(Rule): self.halfwidth = float(self.list[3])/2. except ValueError : self.halfwidth = None - if self.halfwidth!=None and self.halfwidth<= 0. : + if self.halfwidth is not None and self.halfwidth<= 0. : self.halfwidth = None else : self.halfwidth = -1 @@ -80,7 +80,7 @@ class InLatLonNeighborhood(Rule): #we allow a band instead of a triangle self.lat, self.lon = PlaceUtils.conv_lat_lon(self.list[0],self.list[1],"D.D8") - if self.lat != None and self.lon != None : + if self.lat is not None and self.lon is not None : self.lat = float(self.lat) self.lon = float(self.lon) else : @@ -88,13 +88,13 @@ class InLatLonNeighborhood(Rule): #we define the two squares we must look in # can be 0, so check on None - if self.lat!=None and self.halfheight!=None and self.halfheight != -1 : + if self.lat is not None and self.halfheight is not None and self.halfheight != -1 : self.S = self.lat + self.halfheight if self.S > 90. : self.S = 90. self.N = self.lat - self.halfheight if self.N < -90. : self.N = -90. self.doublesquares = False - if self.lon!=None and self.halfwidth!=None and self.halfwidth != -1 : + if self.lon is not None and self.halfwidth is not None and self.halfwidth != -1 : if self.halfwidth >= 180. : #the entire longitude is allowed, reset values self.lon = 0. @@ -122,11 +122,11 @@ class InLatLonNeighborhood(Rule): return False # when given, must be valid - if self.lat == None or self.lon == None : + if self.lat is None or self.lon is None : return False # if height/width given, they must be valid - if self.halfheight == None or self.halfwidth == None : + if self.halfheight is None or self.halfwidth is None : return False #now we know at least one is given in the filter and is valid diff --git a/src/Filters/Rules/_HasNoteRegexBase.py b/src/Filters/Rules/_HasNoteRegexBase.py index 3774f71a4..562ab68c9 100644 --- a/src/Filters/Rules/_HasNoteRegexBase.py +++ b/src/Filters/Rules/_HasNoteRegexBase.py @@ -60,6 +60,6 @@ class HasNoteRegexBase(Rule): for notehandle in notelist: note = db.get_note_from_handle(notehandle) n = unicode(note.get(False)) - if self.match.match(n) != None: + if self.match.match(n) is not None: return True return False diff --git a/src/Filters/Rules/_RegExpIdBase.py b/src/Filters/Rules/_RegExpIdBase.py index 9b43a8b79..e2bc4bb89 100644 --- a/src/Filters/Rules/_RegExpIdBase.py +++ b/src/Filters/Rules/_RegExpIdBase.py @@ -60,4 +60,4 @@ class RegExpIdBase(Rule): self.match = re.compile('') def apply(self, db, obj): - return self.match.match(obj.gramps_id) != None + return self.match.match(obj.gramps_id) is not None diff --git a/src/Filters/Rules/_Rule.py b/src/Filters/Rules/_Rule.py index 53c1e7f05..5fb86275c 100644 --- a/src/Filters/Rules/_Rule.py +++ b/src/Filters/Rules/_Rule.py @@ -53,7 +53,7 @@ class Rule: pass def set_list(self, arg): - assert isinstance(arg, list) or arg == None, "Argument is not a list" + assert isinstance(arg, list) or arg is None, "Argument is not a list" assert len(arg) == len(self.labels), \ "Number of arguments does not match number of labels.\n"\ "list: %s\nlabels: %s" % (arg,self.labels) diff --git a/src/Filters/_FilterParser.py b/src/Filters/_FilterParser.py index 36d9c9d83..d70636464 100644 --- a/src/Filters/_FilterParser.py +++ b/src/Filters/_FilterParser.py @@ -106,7 +106,7 @@ class FilterParser(handler.ContentHandler): self.a.append(attrs['value']) def endElement(self, tag): - if tag == "rule" and self.r != None: + if tag == "rule" and self.r is not None: if len(self.r.labels) < len(self.a): print "WARNING: Invalid number of arguments in filter '%s'!" %\ self.f.get_name() diff --git a/src/Filters/_GenericFilter.py b/src/Filters/_GenericFilter.py index a1fd9f0f0..4fa0b4760 100644 --- a/src/Filters/_GenericFilter.py +++ b/src/Filters/_GenericFilter.py @@ -115,7 +115,7 @@ class GenericFilter: def check_func(self, db, id_list, task): final_list = [] - if id_list == None: + if id_list is None: cursor = self.get_cursor(db) data = cursor.first() while data: @@ -135,7 +135,7 @@ class GenericFilter: def check_and(self, db, id_list): final_list = [] flist = self.flist - if id_list == None: + if id_list is None: cursor = self.get_cursor(db) data = cursor.first() while data: diff --git a/src/GrampsCfg.py b/src/GrampsCfg.py index d60921f1d..16a540ef7 100644 --- a/src/GrampsCfg.py +++ b/src/GrampsCfg.py @@ -383,7 +383,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): """ model = self.fmt_obox.get_model() iter = model.get_iter_first() - while iter != None: + while iter is not None: othernum = model.get_value(iter, COL_NUM) oldnum = model.get_value(oldnode, COL_NUM) if othernum == oldnum: @@ -531,7 +531,7 @@ class GrampsPreferences(ManagedWindow.ManagedWindow): """ model, self.iter = tree_selection.get_selected() - if self.iter == None: + if self.iter is None: tree_selection.select_path(0) model, self.iter = tree_selection.get_selected() self.selected_fmt = model.get(self.iter, 0, 1, 2) diff --git a/src/GrampsDbUtils/_GedcomParse.py b/src/GrampsDbUtils/_GedcomParse.py index df385562f..b82db9f30 100644 --- a/src/GrampsDbUtils/_GedcomParse.py +++ b/src/GrampsDbUtils/_GedcomParse.py @@ -990,9 +990,9 @@ class GedcomParser(UpdateCallback): # if we haven't we need to get a new GRAMPS ID intid = self.place_names.get(title) - if intid == None: + if intid is None: intid = self.lid2id.get(title) - if intid == None: + if intid is None: new_id = self.dbase.find_next_place_gramps_id() else: new_id = None @@ -2382,7 +2382,7 @@ class GedcomParser(UpdateCallback): self.__parse_level(state, self.family_func, self.__family_even) # handle addresses attached to families - if state.addr != None: + if state.addr is not None: father_handle = family.get_father_handle() father = self.dbase.get_person_from_handle(father_handle) if father: @@ -4286,7 +4286,7 @@ class GedcomParser(UpdateCallback): self.__warn(_("Could not import %s") % filename) path = filename.replace('\\', os.path.sep) photo_handle = self.media_map.get(path) - if photo_handle == None: + if photo_handle is None: photo = gen.lib.MediaObject() photo.set_path(path) photo.set_description(title) diff --git a/src/GrampsDbUtils/_GrampsBSDDB.py b/src/GrampsDbUtils/_GrampsBSDDB.py index 6785c4bc5..90fbf941b 100644 --- a/src/GrampsDbUtils/_GrampsBSDDB.py +++ b/src/GrampsDbUtils/_GrampsBSDDB.py @@ -233,49 +233,49 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): """ returns True if the handle exists in the current Person database. """ - return self.person_map.get(str(handle), txn=self.txn) != None + return self.person_map.get(str(handle), txn=self.txn) is not None def has_family_handle(self, handle): """ returns True if the handle exists in the current Family database. """ - return self.family_map.get(str(handle), txn=self.txn) != None + return self.family_map.get(str(handle), txn=self.txn) is not None def has_object_handle(self, handle): """ returns True if the handle exists in the current MediaObjectdatabase. """ - return self.media_map.get(str(handle), txn=self.txn) != None + return self.media_map.get(str(handle), txn=self.txn) is not None def has_repository_handle(self, handle): """ returns True if the handle exists in the current Repository database. """ - return self.repository_map.get(str(handle), txn=self.txn) != None + return self.repository_map.get(str(handle), txn=self.txn) is not None def has_note_handle(self, handle): """ returns True if the handle exists in the current Note database. """ - return self.note_map.get(str(handle), txn=self.txn) != None + return self.note_map.get(str(handle), txn=self.txn) is not None def has_event_handle(self, handle): """ returns True if the handle exists in the current Repository database. """ - return self.event_map.get(str(handle), txn=self.txn) != None + return self.event_map.get(str(handle), txn=self.txn) is not None def has_place_handle(self, handle): """ returns True if the handle exists in the current Repository database. """ - return self.place_map.get(str(handle), txn=self.txn) != None + return self.place_map.get(str(handle), txn=self.txn) is not None def has_source_handle(self, handle): """ returns True if the handle exists in the current Repository database. """ - return self.source_map.get(str(handle), txn=self.txn) != None + return self.source_map.get(str(handle), txn=self.txn) is not None def get_raw_person_data(self, handle): """ @@ -474,7 +474,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): else: the_txn = None - if gstats == None: + if gstats is None: # New database. Set up the current version. self.metadata.put('version', _DBVERSION, txn=the_txn) elif not self.metadata.has_key('version'): @@ -820,7 +820,7 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): data = self.reference_map.get(data) else: data = pickle.loads(data) - if include_classes == None or \ + if include_classes is None or \ KEY_TO_CLASS_MAP[data[0][0]] in include_classes: yield (KEY_TO_CLASS_MAP[data[0][0]], data[0][1]) @@ -1599,13 +1599,13 @@ class GrampsBSDDB(GrampsDbBase, UpdateCallback): return status def undo_reference(self, data, handle): - if data == None: + if data is None: self.reference_map.delete(handle, txn=self.txn) else: self.reference_map.put(handle, data, txn=self.txn) def undo_data(self, data, handle, db_map, signal_root): - if data == None: + if data is None: self.emit(signal_root + '-delete', ([handle], )) db_map.delete(handle, txn=self.txn) else: diff --git a/src/GrampsDbUtils/_GrampsDbWriteXML.py b/src/GrampsDbUtils/_GrampsDbWriteXML.py index cf99dfbbb..b0a17b420 100644 --- a/src/GrampsDbUtils/_GrampsDbWriteXML.py +++ b/src/GrampsDbUtils/_GrampsDbWriteXML.py @@ -834,7 +834,7 @@ class GrampsDbXmlWriter(UpdateCallback): %(sp,self.fix(date.get_text()))) def write_force_line(self,label,value,indent=1): - if value != None: + if value is not None: self.g.write('%s<%s>%s\n' % (' '*indent,label,self.fix(value),label)) def dump_name(self, name,alternative=False,index=1): @@ -962,15 +962,13 @@ class GrampsDbXmlWriter(UpdateCallback): corner1_y = rect[1] corner2_x = rect[2] corner2_y = rect[3] - if corner1_x==None : corner1_x = 0 - if corner1_y==None : corner1_y = 0 - if corner2_x==None : corner2_x = 100 - if corner2_y==None : corner2_y = 100 + if corner1_x is None : corner1_x = 0 + if corner1_y is None : corner1_y = 0 + if corner2_x is None : corner2_x = 100 + if corner2_y is None : corner2_y = 100 #don't output not set rectangle - if (corner1_x == 0 and corner1_y == 0 - and corner2_x == 0 and corner2_y == 0 - ) or (corner1_x == 0 and corner1_y == 0 - and corner2_x == 100 and corner2_y == 100 + if (corner1_x == corner1_y == corner2_x == corner2_y == 0) or \ + (corner1_x == corner1_y == 0 and corner2_x == corner2_y == 100 ): rect = None if (len(proplist) + len(nreflist) + len(refslist)) == 0 \ @@ -1137,4 +1135,4 @@ def conf_priv(obj): # #------------------------------------------------------------------------- -# Don't export a writer for plugins, that is the task of _WriteXML.py \ No newline at end of file +# Don't export a writer for plugins, that is the task of _WriteXML.py diff --git a/src/GrampsDbUtils/_ReadXML.py b/src/GrampsDbUtils/_ReadXML.py index 68f8a79ed..ab52a2f1e 100644 --- a/src/GrampsDbUtils/_ReadXML.py +++ b/src/GrampsDbUtils/_ReadXML.py @@ -756,7 +756,7 @@ class GrampsParser(UpdateCallback): name_displayer.set_name_format(self.db.name_formats) self.db.set_researcher(self.owner) - if self.home != None: + if self.home is not None: person = self.db.get_person_from_handle(self.home) self.db.set_default_person_handle(person.handle) @@ -971,11 +971,11 @@ class GrampsParser(UpdateCallback): event.personal = True if (event.type == gen.lib.EventType.BIRTH) \ and (self.eventref.role == gen.lib.EventRoleType.PRIMARY) \ - and (self.person.get_birth_ref() == None): + and (self.person.get_birth_ref() is None): self.person.set_birth_ref(self.eventref) elif (event.type == gen.lib.EventType.DEATH) \ and (self.eventref.role == gen.lib.EventRoleType.PRIMARY) \ - and (self.person.get_death_ref() == None): + and (self.person.get_death_ref() is None): self.person.set_death_ref(self.eventref) else: self.person.add_event_ref(self.eventref) @@ -1881,7 +1881,7 @@ class GrampsParser(UpdateCallback): else: text = None - if text != None: + if text is not None: note = gen.lib.Note() note.handle = Utils.create_id() note.set(_("Witness comment: %s") % text) @@ -1963,10 +1963,10 @@ class GrampsParser(UpdateCallback): ref.private = self.event.private ref.role.set(gen.lib.EventRoleType.PRIMARY) if (self.event.type == gen.lib.EventType.BIRTH) \ - and (self.person.get_birth_ref() == None): + and (self.person.get_birth_ref() is None): self.person.set_birth_ref(ref) elif (self.event.type == gen.lib.EventType.DEATH) \ - and (self.person.get_death_ref() == None): + and (self.person.get_death_ref() is None): self.person.set_death_ref(ref) else: self.person.add_event_ref(ref) @@ -2037,7 +2037,7 @@ class GrampsParser(UpdateCallback): """ ##place = None ##handle = None - ##if self.place_ref == None: #todo, add place_ref in start and init + ##if self.place_ref is None: #todo, add place_ref in start and init ## #legacy cody? I see no reason for this, but it was present ## if self.place_map.has_key(tag): ## place = self.place_map[tag] diff --git a/src/GrampsDbUtils/_WriteGedcom.py b/src/GrampsDbUtils/_WriteGedcom.py index b4ac6f012..2d18b2a31 100644 --- a/src/GrampsDbUtils/_WriteGedcom.py +++ b/src/GrampsDbUtils/_WriteGedcom.py @@ -1111,7 +1111,7 @@ class GedcomWriter(BasicUtils.UpdateCallback): +2 MEDI {0:1} """ - if reporef.ref == None: + if reporef.ref is None: return repo = self.dbase.get_repository_from_handle(reporef.ref) @@ -1339,7 +1339,7 @@ class GedcomWriter(BasicUtils.UpdateCallback): """ src_handle = ref.get_reference_handle() - if src_handle == None: + if src_handle is None: return src = self.dbase.get_source_from_handle(src_handle) diff --git a/src/GrampsDbUtils/_WriteGrdb.py b/src/GrampsDbUtils/_WriteGrdb.py index 6cf259c0b..c26f323b1 100644 --- a/src/GrampsDbUtils/_WriteGrdb.py +++ b/src/GrampsDbUtils/_WriteGrdb.py @@ -49,7 +49,7 @@ def cli_callback(val): def exportData(database, filename, person=None, callback=None, cl=False): - if callback == None: + if callback is None: callback = cli_callback filename = os.path.normpath(filename) diff --git a/src/LdsUtils.py b/src/LdsUtils.py index 7d8cf9d4d..6aa1a9a11 100644 --- a/src/LdsUtils.py +++ b/src/LdsUtils.py @@ -66,14 +66,14 @@ class LdsTemples: returns True if the code is a valid LDS temple code according to the lds.xml file """ - return self.__temple_to_abrev.get(code) != None + return self.__temple_to_abrev.get(code) is not None def is_valid_name(self, name): """ returns True if the name matches a temple name (not code) in the lds.xml file """ - return self.__temple_codes.get(name) != None + return self.__temple_codes.get(name) is not None def code(self, name): """ @@ -110,7 +110,7 @@ class LdsTemples: text = ''.join(self.__tlist) if tag == "code": - if self.__temple_codes.get(self.__current_temple) == None: + if self.__temple_codes.get(self.__current_temple) is None: self.__temple_codes[self.__current_temple] = text self.__temple_to_abrev[text] = self.__current_temple diff --git a/src/ListModel.py b/src/ListModel.py index 09909e770..4e7cbe7f7 100644 --- a/src/ListModel.py +++ b/src/ListModel.py @@ -231,7 +231,7 @@ class ListModel: Return the row at the specified (x,y) coordinates """ path = self.tree.get_path_at_pos(xpos, ypos) - if path == None: + if path is None: return self.count -1 else: return path[0][0]-1 diff --git a/src/Lru.py b/src/Lru.py index f015b474b..45a79b1ff 100644 --- a/src/Lru.py +++ b/src/Lru.py @@ -97,7 +97,7 @@ class LRU: Iterate over the LRU """ cur = self.first - while cur != None: + while cur is not None: cur2 = cur.next yield cur.value[1] cur = cur2 @@ -108,7 +108,7 @@ class LRU: Return items in the LRU using a generator """ cur = self.first - while cur != None: + while cur is not None: cur2 = cur.next yield cur.value cur = cur2 diff --git a/src/ManagedWindow.py b/src/ManagedWindow.py index e685d3284..89791fc9e 100644 --- a/src/ManagedWindow.py +++ b/src/ManagedWindow.py @@ -394,7 +394,7 @@ class ManagedWindow: return id(obj) def define_glade(self, top_module, glade_file=None): - if glade_file == None: + if glade_file is None: glade_file = const.GLADE_FILE self._gladeobj = glade.XML(glade_file, top_module, "gramps") return self._gladeobj diff --git a/src/Merge/_MergePerson.py b/src/Merge/_MergePerson.py index 0ceb9e244..3deb0ac8a 100644 --- a/src/Merge/_MergePerson.py +++ b/src/Merge/_MergePerson.py @@ -705,7 +705,7 @@ class MergePeople: ## fam.set_father_handle(self.p1) ## if self.p2 == fam.get_mother_handle(): ## fam.set_mother_handle(self.p1) -## if fam.get_father_handle() == None and fam.get_mother_handle() == None: +## if fam.get_father_handle() is None and fam.get_mother_handle() is None: ## self.delete_empty_family(fam, trans) ## data = cursor.next() diff --git a/src/PageView.py b/src/PageView.py index dc733fe7f..53ae62c6a 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -840,7 +840,7 @@ class ListView(BookMarkView): self.list.set_model(self.model) self.build_columns() - if const.USE_TIPS and self.model.tooltip_column != None: + if const.USE_TIPS and self.model.tooltip_column is not None: self.tooltips = TreeTips.TreeTips( self.list, self.model.tooltip_column, True) self.dirty = False diff --git a/src/PlaceUtils.py b/src/PlaceUtils.py index 7859626c3..2e5a7a0a1 100644 --- a/src/PlaceUtils.py +++ b/src/PlaceUtils.py @@ -237,18 +237,18 @@ def conv_lat_lon(latitude, longitude, format="D.D4"): else: error = True # degs should have a value now - if degs == None: + if degs is None: error = True if error: return None - if v != None: + if v is not None: return v #we have a degree notation, convert to float v = float(degs) - if secs != None: + if secs is not None: v += secs / 3600. - if mins != None: + if mins is not None: v += float(mins) / 60. if sign =="-": v = v * -1. @@ -277,7 +277,7 @@ def conv_lat_lon(latitude, longitude, format="D.D4"): lon_float = convert_float_val(longitude, 'lon') # give output (localized if needed) - if lat_float == None or lon_float == None: + if lat_float is None or lon_float is None: if format == "ISO-D" or format == "ISO-DM" or format == "ISO-DMS": return None else: diff --git a/src/PluginUtils/_GuiOptions.py b/src/PluginUtils/_GuiOptions.py index 4d77112d1..822e0ad4d 100644 --- a/src/PluginUtils/_GuiOptions.py +++ b/src/PluginUtils/_GuiOptions.py @@ -1252,7 +1252,7 @@ class GuiMenuOptions: widget, label = make_gui_option(option, self.__tooltips, dialog.dbstate, dialog.uistate, dialog.track) - if widget == None: + if widget is None: print "UNKNOWN OPTION: ", option else: if label: diff --git a/src/PluginUtils/_PluginMgr.py b/src/PluginUtils/_PluginMgr.py index 1338cda8a..030804c56 100644 --- a/src/PluginUtils/_PluginMgr.py +++ b/src/PluginUtils/_PluginMgr.py @@ -143,7 +143,6 @@ class PluginManager(gen.utils.Callback): self.__success_list.append((filename, _module)) except: self.__failmsg_list.append((filename, sys.exc_info())) - return len(self.__failmsg_list) != 0 # return True if there are errors def reload_plugins(self): diff --git a/src/PluginUtils/_PluginWindows.py b/src/PluginUtils/_PluginWindows.py index 12d99c91b..e0fd53f80 100644 --- a/src/PluginUtils/_PluginWindows.py +++ b/src/PluginUtils/_PluginWindows.py @@ -407,7 +407,7 @@ class ToolManagedWindowBase(ManagedWindow.ManagedWindow): self.frame_names.append(frame_name) def set_current_frame(self, name): - if name == None: + if name is None: self.notebook.set_current_page(0) else: for frame_name in self.frame_names: diff --git a/src/Relationship.py b/src/Relationship.py index f32ae2b36..e1a6ec023 100644 --- a/src/Relationship.py +++ b/src/Relationship.py @@ -888,7 +888,7 @@ class RelationshipCalculator: will be looked up anyway an stored if common. At end the doubles are filtered out """ - if person == None or not person.handle : + if person is None or not person.handle : return if depth > self.__max_depth: @@ -1189,7 +1189,7 @@ class RelationshipCalculator: (relation_string, distance_common_orig, distance_common_other) """ stop = False - if orig_person == None: + if orig_person is None: rel_str = _("undefined") stop = True @@ -1233,7 +1233,7 @@ class RelationshipCalculator: dist_other= len(rel[4]) if len(databest) == 1: birth = self.only_birth(rel[2]) and self.only_birth(rel[4]) - if dist_orig == 1 and dist_other == 1: + if dist_orig == dist_other == 1: rel_str = self.get_sibling_relationship_string( self.get_sibling_type( db, orig_person, other_person), @@ -1287,7 +1287,7 @@ class RelationshipCalculator: dist_orig = len(rel[2]) dist_other= len(rel[4]) birth = self.only_birth(rel[2]) and self.only_birth(rel[4]) - if dist_orig == 1 and dist_other == 1: + if dist_orig == dist_other == 1: rel_str = self.get_sibling_relationship_string( self.get_sibling_type( db, orig_person, other_person), @@ -1314,7 +1314,7 @@ class RelationshipCalculator: """ relstrings = [] commons = {} - if orig_person == None: + if orig_person is None: return ([], []) if orig_person.get_handle() == other_person.get_handle(): @@ -1342,7 +1342,7 @@ class RelationshipCalculator: rel4 = rel4 + self.REL_FAM_BIRTH rel1 = None birth = self.only_birth(rel2) and self.only_birth(rel4) - if dist_orig == 1 and dist_other == 1: + if dist_orig == dist_other == 1: rel_str = self.get_sibling_relationship_string( self.get_sibling_type( db, orig_person, other_person), diff --git a/src/ReportBase/_Bibliography.py b/src/ReportBase/_Bibliography.py index dfdb27875..0af8b882e 100644 --- a/src/ReportBase/_Bibliography.py +++ b/src/ReportBase/_Bibliography.py @@ -187,11 +187,11 @@ class Bibliography: return True if ( self.mode & self.MODE_DATE ) == self.MODE_DATE: date = source_ref.get_date_object() - if date != None and not date.is_empty(): + if date is not None and not date.is_empty(): return True if ( self.mode & self.MODE_CONF ) == self.MODE_CONF: confidence = source_ref.get_confidence_level() - if confidence != None and confidence != SourceRef.CONF_NORMAL: + if confidence is not None and confidence != SourceRef.CONF_NORMAL: return True if ( self.mode & self.MODE_NOTE ) == self.MODE_NOTE: if len(source_ref.get_note_list()) != 0: diff --git a/src/ReportBase/_DocReportDialog.py b/src/ReportBase/_DocReportDialog.py index 11f53769b..93b64af82 100644 --- a/src/ReportBase/_DocReportDialog.py +++ b/src/ReportBase/_DocReportDialog.py @@ -165,7 +165,7 @@ class DocReportDialog(ReportDialog): self.row += 1 ext = self.format_menu.get_ext() - if ext == None: + if ext is None: ext = "" else: spath = self.get_default_directory() diff --git a/src/ReportBase/_Endnotes.py b/src/ReportBase/_Endnotes.py index b76ae0f84..c1ebe56ec 100644 --- a/src/ReportBase/_Endnotes.py +++ b/src/ReportBase/_Endnotes.py @@ -76,7 +76,7 @@ def cite_source(bibliography, obj): first = 0 (cindex, key) = bibliography.add_reference(ref) txt += "%d" % (cindex + 1) - if key != None: + if key is not None: txt += key return txt diff --git a/src/ReportBase/_GraphvizReportDialog.py b/src/ReportBase/_GraphvizReportDialog.py index 939377e68..9d22b6785 100644 --- a/src/ReportBase/_GraphvizReportDialog.py +++ b/src/ReportBase/_GraphvizReportDialog.py @@ -931,7 +931,7 @@ class GraphvizReportDialog(ReportDialog): self.row += 1 ext = self.format_menu.get_ext() - if ext == None: + if ext is None: ext = "" else: spath = self.get_default_directory() diff --git a/src/ReportBase/_ReportUtils.py b/src/ReportBase/_ReportUtils.py index bdcdb4dfa..61954636b 100644 --- a/src/ReportBase/_ReportUtils.py +++ b/src/ReportBase/_ReportUtils.py @@ -1436,7 +1436,7 @@ def estimate_age(db, person, end_handle=None, start_handle=None, today=_TODAY): if dhandle: ddata = db.get_event_from_handle(dhandle).get_date_object() else: - if today != None: + if today is not None: ddata = today else: return (-1, -1) @@ -1461,7 +1461,7 @@ def estimate_age(db, person, end_handle=None, start_handle=None, today=_TODAY): else: return high[2] - low[2] - if bstop == Date.EMPTY and dstop == Date.EMPTY: + if bstop == dstop == Date.EMPTY: lower = _calc_diff(bstart, dstart) age = (lower, lower) elif bstop == Date.EMPTY: @@ -1504,7 +1504,7 @@ def estimate_age_on_date(db, person, ddata=_TODAY): return high[2] - low[2] - 1 else: return high[2] - low[2] - if bstop == Date.EMPTY and dstop == Date.EMPTY: + if bstop == dstop == Date.EMPTY: lower = _calc_diff(bstart, dstart) age = [lower, lower] elif bstop == Date.EMPTY: @@ -1655,7 +1655,7 @@ def born_died_str(database, person, endnotes=None, name_object=None, person_name if not name_object: name_object = person.get_primary_name() - if person_name == None: + if person_name is None: person_name = _nd.display_name(name_object) elif person_name == 0: if person.get_gender() == Person.MALE: @@ -2140,7 +2140,7 @@ def born_str(database, person, person_name=None, verbose=True, """ name_index = 1 - if person_name == None: + if person_name is None: person_name = _nd.display(person) elif person_name == 0: name_index = 0 @@ -2238,7 +2238,7 @@ def died_str(database, person, person_name=None, verbose=True, """ name_index = 1 - if person_name == None: + if person_name is None: person_name = _nd.display(person) elif person_name == 0: name_index = 0 @@ -2321,7 +2321,7 @@ def buried_str(database, person, person_name=None, empty_date="", empty_place="" """ name_index = 0 - if person_name == None: + if person_name is None: person_name = _nd.display(person) elif person_name == 0: name_index = 1 @@ -2606,7 +2606,7 @@ def get_person_mark(db, person): deathEvt = db.get_event_from_handle(death_ref.ref) death = DateHandler.get_date(deathEvt) - if birth == " " and death == " ": + if birth == death == " ": key = name else: key = "%s (%s - %s)" % (name, birth, death) diff --git a/src/ScratchPad.py b/src/ScratchPad.py index 7a918623f..83233acc3 100644 --- a/src/ScratchPad.py +++ b/src/ScratchPad.py @@ -1060,7 +1060,7 @@ class ScratchPadListView: self._widget.unset_rows_drag_source() - if node != None: + if node is not None: o = model.get_value(node,1) targets = [ScratchPadListView.LOCAL_DRAG_TARGET] + \ diff --git a/src/Simple/_SimpleAccess.py b/src/Simple/_SimpleAccess.py index 33122ab46..3d8a43ed6 100644 --- a/src/Simple/_SimpleAccess.py +++ b/src/Simple/_SimpleAccess.py @@ -612,7 +612,7 @@ class SimpleAccess: @rtype: list """ assert(isinstance(obj, (gen.lib.Person, gen.lib.Family, NoneType))) - assert(isinstance(restrict, list) or restrict == None) + assert(isinstance(restrict, list) or restrict is None) if obj: event_handles = [ ref.ref for ref in obj.get_event_ref_list() ] diff --git a/src/Simple/_SimpleTable.py b/src/Simple/_SimpleTable.py index 189d10c22..a022dcc4d 100644 --- a/src/Simple/_SimpleTable.py +++ b/src/Simple/_SimpleTable.py @@ -187,7 +187,7 @@ class SimpleTable: elif isinstance(item, gen.lib.Person): name = self.access.name(item) retval.append(name) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Person', item.handle) elif isinstance(item, gen.lib.Family): father = self.access.father(item) @@ -203,32 +203,32 @@ class SimpleTable: else: text += " " + _("Unknown mother") retval.append(text) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Family', item.handle) elif isinstance(item, gen.lib.Source): retval.append(_('Source')) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Souce', item.handle) elif isinstance(item, gen.lib.Event): name = self.access.event_type(item) retval.append(name) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Event', item.handle) elif isinstance(item, gen.lib.MediaObject): retval.append(_('Media')) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Media', item.handle) elif isinstance(item, gen.lib.Place): retval.append(_('Place')) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Place', item.handle) elif isinstance(item, gen.lib.Repository): retval.append(_('Repository')) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Repository', item.handle) elif isinstance(item, gen.lib.Note): retval.append(_('Note')) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Note', item.handle) elif isinstance(item, gen.lib.Date): text = DateHandler.displayer.display(item) @@ -242,7 +242,7 @@ class SimpleTable: invalid_date_format = Config.get(Config.INVALID_DATE_FORMAT) self.set_cell_markup(col, row, invalid_date_format % text) - if (self.__link_col == col or link == None): + if (self.__link_col == col or link is None): link = ('Date', item) elif isinstance(item, gen.lib.Span): text = str(item) @@ -363,14 +363,14 @@ class SimpleTable: has formatting), or just the plain data. """ if x in self.__cell_markup: - if y == None: + if y is None: return True # markup for this column elif y in self.__cell_markup[x]: return self.__cell_markup[x][y] else: return cgi.escape(data) else: - if y == None: + if y is None: return False # no markup for this column else: return data diff --git a/src/ThumbNails.py b/src/ThumbNails.py index e9071c371..cc38ad5c8 100644 --- a/src/ThumbNails.py +++ b/src/ThumbNails.py @@ -121,7 +121,7 @@ def __build_thumb_path(path, rectangle=None): @returns: full path name to the corresponding thumbnail file. """ extra = "" - if rectangle != None: + if rectangle is not None: extra = "?" + str(rectangle) md5_hash = md5.md5(path+extra) return os.path.join(const.THUMB_DIR, md5_hash.hexdigest()+'.png') @@ -158,7 +158,7 @@ def __create_thumbnail_image(src_file, mtype=None, rectangle=None): width = pixbuf.get_width() height = pixbuf.get_height() - if rectangle != None: + if rectangle is not None: upper_x = min(rectangle[0], rectangle[2])/100. lower_x = max(rectangle[0], rectangle[2])/100. upper_y = min(rectangle[1], rectangle[3])/100. diff --git a/src/TreeTips.py b/src/TreeTips.py index d5f15e5e0..92e191830 100644 --- a/src/TreeTips.py +++ b/src/TreeTips.py @@ -185,7 +185,7 @@ class TreeTips(gtk.Widget): return False pathReturn = tree.get_path_at_pos(xEvent, yEvent) model = tree.get_model() - if pathReturn == None: + if pathReturn is None: self.path = None elif self.path != pathReturn[0]: self.path = pathReturn[0] diff --git a/src/Utils.py b/src/Utils.py index a981a763c..3033d8178 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -138,7 +138,7 @@ def fix_encoding(value): def xml_lang(): loc = locale.getlocale() - if loc[0] == None: + if loc[0] is None: return "" else: return loc[0].replace('_', '-') @@ -578,7 +578,7 @@ def probably_alive(person, db, current_date=None, limit=0): (defaults to today) limit - number of years to check beyond death_date """ - if current_date == None: + if current_date is None: current_date = gen.lib.Date() # yr, mon, day: current_date.set_yr_mon_day(*time.localtime(time.time())[0:3]) diff --git a/src/ViewManager.py b/src/ViewManager.py index a8824e7f6..9eb10dc75 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -969,12 +969,12 @@ class ViewManager: Initialize the navigation scheme """ old_nav = self._navigation_type[self.prev_nav] - if old_nav[0] != None: + if old_nav[0] is not None: old_nav[0].disable() page_type = self.active_page.navigation_type() nav_type = self._navigation_type[page_type] - if nav_type[0] != None: + if nav_type[0] is not None: nav_type[0].enable() def change_page(self, obj, page, num=-1): diff --git a/src/data/authors.xml b/src/data/authors.xml index f8bada344..5d9d5be18 100644 --- a/src/data/authors.xml +++ b/src/data/authors.xml @@ -76,4 +76,7 @@ Zsolt Foldvari <zfoldvar@users.sourceforge.net> + + Gerald Britton <gerald.britton@gmail.com> + diff --git a/src/docgen/HtmlDoc.py b/src/docgen/HtmlDoc.py index 2d1569986..153c952c0 100644 --- a/src/docgen/HtmlDoc.py +++ b/src/docgen/HtmlDoc.py @@ -146,7 +146,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): top_add = 0 elif bottom_add == 0: match = stop.search(line) - if match != None: + if match is not None: bottom_add = 1 self.bottom.append(line) else: @@ -172,7 +172,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): top_add = 0 elif bottom_add == 0: match = stop.search(line) - if match != None: + if match is not None: bottom_add = 1 self.bottom.append(line) else: @@ -245,7 +245,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): self.fix_title("".join(self.top)) def fix_title(self,msg=None): - if msg == None: + if msg is None: match = t_header_line_re.match(self.file_header) else: match = t_header_line_re.match(msg) @@ -428,7 +428,7 @@ class HtmlDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): def start_paragraph(self,style_name,leader=None): self.f.write('

') - if leader != None: + if leader is not None: self.f.write(leader) self.f.write(' ') diff --git a/src/docgen/LaTeXDoc.py b/src/docgen/LaTeXDoc.py index 8547c9870..6c318349c 100644 --- a/src/docgen/LaTeXDoc.py +++ b/src/docgen/LaTeXDoc.py @@ -326,15 +326,15 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): self.indent = ltxstyle.leftIndent self.FLindent = ltxstyle.firstLineIndent - if self.indent != None and not self.in_table: + if self.indent is not None and not self.in_table: myspace = '%scm' % str(self.indent) self.f.write('\\grampsindent{%s}\n' % myspace) self.fix_indent = 1 - if leader != None and not self.in_list: + if leader is not None and not self.in_list: self.f.write('\\begin{enumerate}\n') self.in_list = 1 - if leader != None: + if leader is not None: # try obtaining integer leader_1 = leader[:-1] num = roman2arabic(leader_1) @@ -356,7 +356,7 @@ class LaTeXDoc(BaseDoc.BaseDoc,BaseDoc.TextDoc): self.f.write(' \\addtocounter{enumi}{-1}\n') self.f.write(' \\item ') - if leader == None and not self.in_list and not self.in_table: + if leader is None and not self.in_list and not self.in_table: self.f.write('\n') self.f.write('%s ' % self.fbeg) diff --git a/src/docgen/ODFDoc.py b/src/docgen/ODFDoc.py index 5a72dceb3..5989db7d8 100644 --- a/src/docgen/ODFDoc.py +++ b/src/docgen/ODFDoc.py @@ -847,7 +847,7 @@ class ODFDoc(BaseDoc.BaseDoc, BaseDoc.TextDoc, BaseDoc.DrawDoc): self.cntnt.write('') - if leader != None: + if leader is not None: self.cntnt.write(leader) self.cntnt.write('') self.new_cell = 0 diff --git a/src/docgen/PSDrawDoc.py b/src/docgen/PSDrawDoc.py index 321be39af..ec6791d89 100644 --- a/src/docgen/PSDrawDoc.py +++ b/src/docgen/PSDrawDoc.py @@ -58,9 +58,9 @@ try: except: pass -if print_label == None: +if print_label is None: # Second, try to print directly - if get_print_dialog_app() != None: + if get_print_dialog_app() is not None: print_label = _("Print a copy") #------------------------------------------------------------------------- diff --git a/src/gen/db/base.py b/src/gen/db/base.py index 288b6e041..8dafb3f19 100644 --- a/src/gen/db/base.py +++ b/src/gen/db/base.py @@ -1717,7 +1717,7 @@ class GrampsDbBase(Callback): if self.undoindex >= _UNDO_SIZE or self.readonly: return False - if self.translist[self.undoindex+1] == None: + if self.translist[self.undoindex+1] is None: return False return True @@ -1811,7 +1811,7 @@ class GrampsDbBase(Callback): pass def undo_data(self, data, handle, db_map, signal_root): - if data == None: + if data is None: self.emit(signal_root + '-delete', ([handle], )) del db_map[handle] else: @@ -1924,7 +1924,7 @@ class GrampsDbBase(Callback): def set_default_person_handle(self, handle): """Set the default Person to the passed instance.""" - if (self.metadata != None) and (not self.readonly): + if (self.metadata is not None) and (not self.readonly): self.metadata['default'] = str(handle) def get_default_person(self): @@ -1932,13 +1932,13 @@ class GrampsDbBase(Callback): person = self.get_person_from_handle(self.get_default_handle()) if person: return person - elif (self.metadata != None) and (not self.readonly): + elif (self.metadata is not None) and (not self.readonly): self.metadata['default'] = None return None def get_default_handle(self): """Return the default Person of the database.""" - if self.metadata != None: + if self.metadata is not None: return self.metadata.get('default') return None @@ -2252,17 +2252,17 @@ class GrampsDbBase(Callback): def set_mediapath(self, path): """Set the default media path for database, path should be utf-8.""" - if (self.metadata != None) and (not self.readonly): + if (self.metadata is not None) and (not self.readonly): self.metadata['mediapath'] = path def get_mediapath(self): """Return the default media path of the database.""" - if self.metadata != None: + if self.metadata is not None: return self.metadata.get('mediapath', None) return None def set_column_order(self, col_list, name): - if (self.metadata != None) and (not self.readonly): + if (self.metadata is not None) and (not self.readonly): self.metadata[name] = col_list def set_person_column_order(self, col_list): @@ -2321,7 +2321,7 @@ class GrampsDbBase(Callback): self.set_column_order(col_list, NOTE_COL_KEY) def __get_column_order(self, name, default): - if self.metadata == None: + if self.metadata is None: return default else: cols = self.metadata.get(name, default) @@ -2496,7 +2496,7 @@ class GrampsDbBase(Callback): # Find which tables to iterate over - if (include_classes == None): + if (include_classes is None): the_tables = primary_tables.keys() else: the_tables = include_classes @@ -2627,7 +2627,7 @@ class Transaction: """ self.last = self.db.append( cPickle.dumps((obj_type, handle, old_data, new_data), 1)) - if self.first == None: + if self.first is None: self.first = self.last def get_recnos(self): diff --git a/src/gen/db/dbdir.py b/src/gen/db/dbdir.py index a7dfa6439..6408ce142 100644 --- a/src/gen/db/dbdir.py +++ b/src/gen/db/dbdir.py @@ -262,7 +262,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback): def __has_handle(self, table, handle): try: - return table.get(str(handle), txn=self.txn) != None + return table.get(str(handle), txn=self.txn) is not None except DBERRS, msg: self.__log_error() raise Errors.DbError(msg) @@ -537,7 +537,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback): # Start transaction the_txn = self.env.txn_begin() - if gstats == None: + if gstats is None: # New database. Set up the current version. self.metadata.put('version', _DBVERSION, txn=the_txn) elif not self.metadata.has_key('version'): @@ -876,7 +876,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback): data = self.reference_map.get(data) else: data = pickle.loads(data) - if include_classes == None or \ + if include_classes is None or \ KEY_TO_CLASS_MAP[data[0][0]] in include_classes: yield (KEY_TO_CLASS_MAP[data[0][0]], data[0][1]) @@ -1664,7 +1664,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback): def undo_reference(self, data, handle): try: - if data == None: + if data is None: self.reference_map.delete(handle, txn=self.txn) else: self.reference_map.put(handle, data, txn=self.txn) @@ -1674,7 +1674,7 @@ class GrampsDBDir(GrampsDbBase, UpdateCallback): def undo_data(self, data, handle, db_map, signal_root): try: - if data == None: + if data is None: self.emit(signal_root + '-delete', ([handle],)) db_map.delete(handle, txn=self.txn) else: diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index a4e0a622b..a848bc9ee 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -97,7 +97,7 @@ class Span: ) # number of months, for sorting def __eq__(self, other): - if other == None: + if other is None: return False return self.diff_tuple == other.diff_tuple @@ -204,15 +204,15 @@ class Date: raise AttributeError, "invalid args to Date: %s" % source #### ok, process either date or tuple if isinstance(source, tuple): - if calendar == None: + if calendar is None: self.calendar = Date.CAL_GREGORIAN else: self.calendar = self.lookup_calendar(calendar) - if modifier == None: + if modifier is None: self.modifier = Date.MOD_NONE else: self.modifier = self.lookup_modifier(modifier) - if quality == None: + if quality is None: self.quality = Date.QUAL_NONE else: self.quality = self.lookup_quality(quality) @@ -222,9 +222,9 @@ class Date: self.newyear = 0 self.set_yr_mon_day(*source) elif isinstance(source, str) and source != "": - if (calendar != None or - modifier != None or - quality != None): + if (calendar is not None or + modifier is not None or + quality is not None): raise AttributeError("can't set calendar, modifier, or " "quality with string date") import DateHandler @@ -972,7 +972,7 @@ class Date: year = max(value[Date._POS_YR], 1) month = max(value[Date._POS_MON], 1) day = max(value[Date._POS_DAY], 1) - if year == 0 and month == 0 and day == 0: + if year == month == 0 and day == 0: self.sortval = 0 else: func = Date._calendar_convert[calendar] @@ -995,7 +995,7 @@ class Date: year = max(self.dateval[Date._POS_YR], 1) month = max(self.dateval[Date._POS_MON], 1) day = max(self.dateval[Date._POS_DAY], 1) - if year == 0 and month == 0 and day == 0: + if year == month == 0 and day == 0: self.sortval = 0 else: func = Date._calendar_convert[self.calendar] diff --git a/src/gen/lib/datebase.py b/src/gen/lib/datebase.py index d48f91b7e..d90e1b797 100644 --- a/src/gen/lib/datebase.py +++ b/src/gen/lib/datebase.py @@ -57,7 +57,7 @@ class DateBase: """ Convert the object to a serialized tuple of data. """ - if self.date == None or (self.date.is_empty() and not self.date.text): + if self.date is None or (self.date.is_empty() and not self.date.text): date = None else: date = self.date.serialize(no_text_date) diff --git a/src/gen/lib/event.py b/src/gen/lib/event.py index f05980064..c8f11f3ee 100644 --- a/src/gen/lib/event.py +++ b/src/gen/lib/event.py @@ -255,7 +255,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase, @returns: True if the Events are equal @rtype: bool """ - if other == None: + if other is None: other = Event (None) if self.__type != other.__type or \ @@ -314,3 +314,4 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase, """ return self.__description description = property(get_description, set_description, None, 'Returns or sets description of the event') + diff --git a/src/gen/lib/eventref.py b/src/gen/lib/eventref.py index 1e044b1aa..3a9aca0d0 100644 --- a/src/gen/lib/eventref.py +++ b/src/gen/lib/eventref.py @@ -204,3 +204,4 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase): """ self.__role.set(role) role = property(get_role, set_role, None, 'Returns or sets role property') + diff --git a/src/gen/lib/familyreltype.py b/src/gen/lib/familyreltype.py index d4e3f9866..e8f4795f0 100644 --- a/src/gen/lib/familyreltype.py +++ b/src/gen/lib/familyreltype.py @@ -56,6 +56,6 @@ class FamilyRelType(GrampsType): ] def __init__(self, value=None): - if value == None: + if value is None: value = self.UNKNOWN GrampsType.__init__(self, value) diff --git a/src/gen/lib/genderstats.py b/src/gen/lib/genderstats.py index c7d53aec9..556e28f75 100644 --- a/src/gen/lib/genderstats.py +++ b/src/gen/lib/genderstats.py @@ -44,7 +44,7 @@ class GenderStats: indicating the gender of the person. """ def __init__ (self, stats={}): - if stats == None: + if stats is None: self.stats = {} else: self.stats = stats diff --git a/src/gen/lib/place.py b/src/gen/lib/place.py index 8e0501036..8658054b2 100644 --- a/src/gen/lib/place.py +++ b/src/gen/lib/place.py @@ -95,7 +95,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject): @rtype: tuple """ - if self.main_loc == None or self.main_loc.serialize() == _EMPTY_LOC: + if self.main_loc is None or self.main_loc.serialize() == _EMPTY_LOC: main_loc = None else: main_loc = self.main_loc.serialize() diff --git a/src/gen/lib/test/date_test.py b/src/gen/lib/test/date_test.py index 4d41353e5..f811af654 100644 --- a/src/gen/lib/test/date_test.py +++ b/src/gen/lib/test/date_test.py @@ -226,7 +226,7 @@ class Tester(unittest.TestCase): """ Tests two GRAMPS dates to see if they match. """ - if expected2 == None: + if expected2 is None: expected2 = expected1 date1 = _dp.parse(d1) date2 = _dp.parse(d2) diff --git a/src/gen/proxy/living.py b/src/gen/proxy/living.py index b8cc4bc0c..ad6c4a6d5 100644 --- a/src/gen/proxy/living.py +++ b/src/gen/proxy/living.py @@ -76,7 +76,7 @@ class LivingProxyDb(ProxyDbBase): """ ProxyDbBase.__init__(self, dbase) self.mode = mode - if current_year != None: + if current_year is not None: self.current_date = Date() self.current_date.set_year(current_year) else: diff --git a/src/gen/utils/callback.py b/src/gen/utils/callback.py index 8752031c2..5a726854b 100644 --- a/src/gen/utils/callback.py +++ b/src/gen/utils/callback.py @@ -343,7 +343,7 @@ class Callback(object): self._current_signals.append(signal_name) # check that args is a tuple. This is a common programming error. - if not (isinstance(args, tuple) or args == None): + if not (isinstance(args, tuple) or args is None): self._warn("Signal emitted with argument that is not a tuple.\n" " emit() takes two arguments, the signal name and a \n" " tuple that contains the arguments that are to be \n" @@ -359,7 +359,7 @@ class Callback(object): # type check arguments arg_types = self.__signal_map[signal_name] - if arg_types == None and len(args) > 0: + if arg_types is None and len(args) > 0: self._warn("Signal emitted with " "wrong number of args: %s\n" " from: file: %s\n" @@ -378,7 +378,7 @@ class Callback(object): % ((str(signal_name), ) + inspect.stack()[1][1:4])) return - if arg_types != None: + if arg_types is not None: for i in range(0, len(arg_types)): if not isinstance(args[i], arg_types[i]): self._warn("Signal emitted with " diff --git a/src/gen/utils/dbutils.py b/src/gen/utils/dbutils.py index 4d3f5f92b..5ccd0dbe9 100644 --- a/src/gen/utils/dbutils.py +++ b/src/gen/utils/dbutils.py @@ -73,7 +73,7 @@ def delete_person_from_database(db, person, trans): def remove_family_relationships(db, family_handle, trans=None): family = db.get_family_from_handle(family_handle) - if trans == None: + if trans is None: need_commit = True trans = db.transaction_begin() else: @@ -105,7 +105,7 @@ def remove_parent_from_family(db, person_handle, family_handle, trans=None): person = db.get_person_from_handle(person_handle) family = db.get_family_from_handle(family_handle) - if trans == None: + if trans is None: need_commit = True trans = db.transaction_begin() else: @@ -144,7 +144,7 @@ def remove_child_from_family(db, person_handle, family_handle, trans=None): person.remove_parent_family_handle(family_handle) family.remove_child_handle(person_handle) - if trans == None: + if trans is None: need_commit = True trans = db.transaction_begin() else: @@ -186,7 +186,7 @@ def add_child_to_family(db, family, child, family.add_child_ref(cref) child.add_parent_family_handle(family.handle) - if trans == None: + if trans is None: need_commit = True trans = db.transaction_begin() else: diff --git a/src/gen/utils/progressmon.py b/src/gen/utils/progressmon.py index a3b404f20..d7aa2f38b 100644 --- a/src/gen/utils/progressmon.py +++ b/src/gen/utils/progressmon.py @@ -83,14 +83,14 @@ class ProgressMonitor(object): self._title = title self._popup_time = popup_time - if self._popup_time == None: + if self._popup_time is None: self._popup_time = self.__class__.__default_popup_time self._status_stack = [] # list of current status objects self._dlg = None def _get_dlg(self): - if self._dlg == None: + if self._dlg is None: self._dlg = self._dialog_class(self._dialog_class_params, self._title) @@ -134,7 +134,7 @@ class ProgressMonitor(object): if facade.active: dlg = self._get_dlg() - if facade.pbar_idx == None: + if facade.pbar_idx is None: facade.pbar_idx = dlg.add(facade.status_obj) dlg.show() diff --git a/src/plugins/AgeOnDate.py b/src/plugins/AgeOnDate.py index 1b4e9e5e1..0c9bad9dd 100644 --- a/src/plugins/AgeOnDate.py +++ b/src/plugins/AgeOnDate.py @@ -62,10 +62,10 @@ def run(database, document, date): if birth_date: if (birth_date.get_valid() and birth_date < date and birth_date.get_year() != 0 and - ((death_date == None) or (death_date > date))): + ((death_date is None) or (death_date > date))): diff_tuple = (date - birth_date) - if ((death_date != None) or - (death_date == None and + if ((death_date is not None) or + (death_date is None and diff_tuple[0] <= Config.get(Config.MAX_AGE_PROB_ALIVE))): birth_str = str(diff_tuple) birth_sort = int(diff_tuple) diff --git a/src/plugins/Calendar.py b/src/plugins/Calendar.py index fff0d1dac..8e8899cf6 100644 --- a/src/plugins/Calendar.py +++ b/src/plugins/Calendar.py @@ -159,8 +159,8 @@ class Calendar(Report): married_name = n break # use first # Now, decide which to use: - if maiden_name != None: - if married_name != None: + if maiden_name is not None: + if married_name is not None: name = gen.lib.Name(married_name) else: name = gen.lib.Name(primary_name) @@ -326,7 +326,7 @@ class Calendar(Report): if birth_ref: birth_event = self.database.get_event_from_handle(birth_ref.ref) birth_date = birth_event.get_date_object() - if self.birthdays and birth_date != None: + if self.birthdays and birth_date is not None: year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() @@ -347,7 +347,7 @@ class Calendar(Report): if mother_handle == person_handle: if father_handle: father = self.database.get_person_from_handle(father_handle) - if father != None: + if father is not None: father_lastname = father.get_primary_name().get_surname() short_name = self.get_name(person, father_lastname) if age >= 0: @@ -390,7 +390,7 @@ class Calendar(Report): gen.lib.EventType.ANNULMENT, gen.lib.EventType.DIV_FILING]: are_married = None - if are_married != None: + if are_married is not None: for event_ref in fam.get_event_ref_list(): event = self.database.get_event_from_handle(event_ref.ref) event_obj = event.get_date_object() @@ -598,7 +598,7 @@ class CalendarOptions(MenuReportOptions): g.set_paragraph_style(name) if shadow: g.set_shadow(*shadow) - if color != None: + if color is not None: g.set_fill_color(color) if not borders: g.set_line_width(0) diff --git a/src/plugins/ChangeNames.py b/src/plugins/ChangeNames.py index 883abe907..528b9c47d 100644 --- a/src/plugins/ChangeNames.py +++ b/src/plugins/ChangeNames.py @@ -96,7 +96,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow): lSP = len(namesplitSP) namesplitHY= name.split('-') lHY = len(namesplitHY) - if lSP == 1 and lHY == 1: + if lSP == lHY == 1: if name != name.capitalize(): # Single surname without hyphen(s) self.name_list.append(name) @@ -156,7 +156,7 @@ class ChangeNames(Tool.BatchTool, ManagedWindow.ManagedWindow): namesep = '-' namesplitSP = name.replace(namesep,' ').split() lSP= len(namesplitSP) - if lSP == 1 and lHY == 1: + if lSP == lHY == 1: #if name != name.capitalize(): # Single surname without space(s) or hyphen(s), normal case return name.capitalize() diff --git a/src/plugins/Check.py b/src/plugins/Check.py index 60410caf9..48691f7ac 100644 --- a/src/plugins/Check.py +++ b/src/plugins/Check.py @@ -151,7 +151,7 @@ class Check(Tool.BatchTool): if self.fail: return - cli = uistate == None + cli = uistate is None if self.db.readonly: # TODO: split plugin in a check and repair part to support diff --git a/src/plugins/DefaultGramplets.py b/src/plugins/DefaultGramplets.py index fb142a59c..5b99a15cc 100644 --- a/src/plugins/DefaultGramplets.py +++ b/src/plugins/DefaultGramplets.py @@ -120,7 +120,7 @@ class CalendarGramplet(Gramplet): if birth_ref: birth_event = self.gui.dbstate.db.get_event_from_handle(birth_ref.ref) birth_date = birth_event.get_date_object() - if self.birthdays and birth_date != None: + if self.birthdays and birth_date is not None: year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() @@ -909,7 +909,7 @@ class PythonGramplet(Gramplet): buffer.place_cursor(end) return True _retval = self.process_command(line) - if _retval != None: + if _retval is not None: self.append_text("%s\n" % str(_retval)) self.append_text("%s " % self.prompt) end = buffer.get_end_iter() diff --git a/src/plugins/DetAncestralReport.py b/src/plugins/DetAncestralReport.py index 76cc4489e..096eefa88 100644 --- a/src/plugins/DetAncestralReport.py +++ b/src/plugins/DetAncestralReport.py @@ -180,7 +180,7 @@ class DetAncestorReport(Report): for family_handle in person.get_family_handle_list(): family = self.database.get_family_from_handle(family_handle) mother_handle = family.get_mother_handle() - if mother_handle == None or \ + if mother_handle is None or \ person.get_gender() == gen.lib.Person.FEMALE: if self.listchildren: self.write_children(family) diff --git a/src/plugins/ExportCSV.py b/src/plugins/ExportCSV.py index c7c086e2d..32173356c 100644 --- a/src/plugins/ExportCSV.py +++ b/src/plugins/ExportCSV.py @@ -258,7 +258,7 @@ class CSVWriter: self.include_marriages = self.option_box.include_marriages self.include_children = self.option_box.include_children - if self.option_box.cfilter == None: + if self.option_box.cfilter is None: for p in self.db.get_person_handles(sort_handles=False): self.plist[p] = 1 else: diff --git a/src/plugins/ExportVCalendar.py b/src/plugins/ExportVCalendar.py index 4157687d2..b7939c4c6 100644 --- a/src/plugins/ExportVCalendar.py +++ b/src/plugins/ExportVCalendar.py @@ -156,7 +156,7 @@ class CalendarWriter: else: self.option_box.parse_options() - if self.option_box.cfilter == None: + if self.option_box.cfilter is None: for p in self.db.get_person_handles(sort_handles=False): self.plist[p] = 1 else: diff --git a/src/plugins/ExportVCard.py b/src/plugins/ExportVCard.py index 64f04138c..4c9e24945 100644 --- a/src/plugins/ExportVCard.py +++ b/src/plugins/ExportVCard.py @@ -145,7 +145,7 @@ class CardWriter: else: self.option_box.parse_options() - if self.option_box.cfilter == None: + if self.option_box.cfilter is None: for p in self.db.get_person_handles(sort_handles=False): self.plist[p] = 1 else: diff --git a/src/plugins/FamilyGroup.py b/src/plugins/FamilyGroup.py index 7cba77cff..3523a83ac 100644 --- a/src/plugins/FamilyGroup.py +++ b/src/plugins/FamilyGroup.py @@ -407,7 +407,7 @@ class FamilyGroup(Report): spouse_count = spouse_count + 1 self.doc.start_row() - if spouse_count != 0 or self.missingInfo or death != None or birth != None: + if spouse_count != 0 or self.missingInfo or death is not None or birth is not None: self.doc.start_cell('FGR-TextChild1') else: self.doc.start_cell('FGR-TextChild2') @@ -431,13 +431,13 @@ class FamilyGroup(Report): self.doc.end_cell() self.doc.end_row() - if self.missingInfo or birth != None: - if spouse_count != 0 or self.missingInfo or death != None: + if self.missingInfo or birth is not None: + if spouse_count != 0 or self.missingInfo or death is not None: self.dump_child_event('FGR-TextChild1',_('Birth'),birth) else: self.dump_child_event('FGR-TextChild2',_('Birth'),birth) - if self.missingInfo or death != None: + if self.missingInfo or death is not None: if spouse_count == 0 or not self.incChiMar: self.dump_child_event('FGR-TextChild2',_('Death'),death) else: diff --git a/src/plugins/GVFamilyLines.py b/src/plugins/GVFamilyLines.py index 4df09fb98..b16cd658f 100644 --- a/src/plugins/GVFamilyLines.py +++ b/src/plugins/GVFamilyLines.py @@ -579,8 +579,8 @@ class FamilyLinesReport(Report): 'xmlcharrefreplace') # see if the spouse has parents - if spouse_father_handle == None and \ - spouse_mother_handle == None: + if spouse_father_handle is None and \ + spouse_mother_handle is None: for family_handle in \ spouse.get_parent_family_handle_list(): family = self._db.get_family_from_handle( @@ -616,12 +616,12 @@ class FamilyLinesReport(Report): # if this person has parents, then we automatically keep # this person - if father_handle != None or mother_handle != None: + if father_handle is not None or mother_handle is not None: continue # if the spouse has parents, then we automatically keep # this person - if spouse_father_handle != None or spouse_mother_handle != None: + if spouse_father_handle is not None or spouse_mother_handle is not None: continue # if this is a person of interest, then we automatically keep diff --git a/src/plugins/ImportCSV.py b/src/plugins/ImportCSV.py index e95bdf298..006c27c70 100644 --- a/src/plugins/ImportCSV.py +++ b/src/plugins/ImportCSV.py @@ -345,12 +345,12 @@ class CSVParser: return data def lookup(self, type, id): - if id == None: return None + if id is None: return None if type == "family": if id.startswith("[") and id.endswith("]"): id = id[1:-1] db_lookup = self.db.get_family_from_gramps_id(id) - if db_lookup == None: + if db_lookup is None: return self.lookup(type, id) else: return db_lookup @@ -362,7 +362,7 @@ class CSVParser: if id.startswith("[") and id.endswith("]"): id = id[1:-1] db_lookup = self.db.get_person_from_gramps_id(id) - if db_lookup == None: + if db_lookup is None: return self.lookup(type, id) else: return db_lookup @@ -408,7 +408,7 @@ class CSVParser: header = None # clear headers, ready for next "table" continue ###################################### - if header == None: + if header is None: header = map(cleanup_column_name, row) col = {} count = 0 @@ -430,7 +430,7 @@ class CSVParser: note = rd(line_number, row, col, "note") wife = self.lookup("person", wife) husband = self.lookup("person", husband) - if husband == None and wife == None: + if husband is None and wife is None: # might have children, so go ahead and add print "Warning: no parents on line %d; adding family anyway" % line_number family = self.get_or_create_family(marriage_ref, husband, wife) @@ -475,7 +475,7 @@ class CSVParser: elif "family" in header: # family, child family_ref = rd(line_number, row, col, "family") - if family_ref == None: + if family_ref is None: print "Error: no family reference found for family on line %d" % line_number continue # required child = rd(line_number, row, col, "child") @@ -484,10 +484,10 @@ class CSVParser: gender = rd(line_number, row, col, "gender") child = self.lookup("person", child) family = self.lookup("family", family_ref) - if family == None: + if family is None: print "Error: no matching family reference found for family on line %d" % line_number continue - if child == None: + if child is None: print "Error: no matching child reference found for family on line %d" % line_number continue # is this child already in this family? If so, don't add @@ -557,8 +557,8 @@ class CSVParser: ######################################################### # if this person already exists, don't create them person = self.lookup("person", person_ref) - if person == None: - if surname == None: + if person is None: + if surname is None: print "Warning: empty surname for new person on line %d" % line_number surname = "" # new person @@ -571,31 +571,31 @@ class CSVParser: else: name = person.get_primary_name() ######################################################### - if person_ref != None: + if person_ref is not None: self.storeup("person", person_ref, person) # replace - if callname != None: + if callname is not None: name.set_call_name(callname) - if title != None: + if title is not None: name.set_title(title) - if prefix != None: + if prefix is not None: name.prefix = prefix name.group_as = '' # HELP? what should I do here? - if suffix != None: + if suffix is not None: name.set_suffix(suffix) - if note != None: + if note is not None: # append notes, if previous notes previous_notes = person.get_note() if previous_notes != "": if note not in previous_notes: note = previous_notes + "\n" + note person.set_note(note) - if grampsid != None: + if grampsid is not None: person.gramps_id = grampsid - elif person_ref != None: + elif person_ref is not None: if person_ref.startswith("[") and person_ref.endswith("]"): person.gramps_id = person_ref[1:-1] - if person.get_gender() == gen.lib.Person.UNKNOWN and gender != None: + if person.get_gender() == gen.lib.Person.UNKNOWN and gender is not None: gender = gender.lower() if gender == gender_map[gen.lib.Person.MALE]: gender = gen.lib.Person.MALE @@ -606,25 +606,25 @@ class CSVParser: person.set_gender(gender) ######################################################### # add if new, replace if different - if birthdate != None: + if birthdate is not None: birthdate = _dp.parse(birthdate) - if birthplace != None: + if birthplace is not None: new, birthplace = self.get_or_create_place(birthplace) - if birthsource != None: + if birthsource is not None: new, birthsource = self.get_or_create_source(birthsource) if birthdate or birthplace or birthsource: new, birth = self.get_or_create_event(person, gen.lib.EventType.BIRTH, birthdate, birthplace, birthsource) birth_ref = person.get_birth_ref() - if birth_ref == None: + if birth_ref is None: # new birth_ref = gen.lib.EventRef() birth_ref.set_reference_handle( birth.get_handle()) person.set_birth_ref( birth_ref) - if deathdate != None: + if deathdate is not None: deathdate = _dp.parse(deathdate) - if deathplace != None: + if deathplace is not None: new, deathplace = self.get_or_create_place(deathplace) - if deathsource != None: + if deathsource is not None: new, deathsource = self.get_or_create_source(deathsource) if deathdate or deathplace or deathsource or deathcause: new, death = self.get_or_create_event(person, gen.lib.EventType.DEATH, deathdate, deathplace, deathsource) @@ -632,7 +632,7 @@ class CSVParser: death.set_description(deathcause) self.db.commit_event(death, self.trans) death_ref = person.get_death_ref() - if death_ref == None: + if death_ref is None: # new death_ref = gen.lib.EventRef() death_ref.set_reference_handle(death.get_handle()) diff --git a/src/plugins/ImportGeneWeb.py b/src/plugins/ImportGeneWeb.py index be71abba5..f5e4b0621 100644 --- a/src/plugins/ImportGeneWeb.py +++ b/src/plugins/ImportGeneWeb.py @@ -143,7 +143,7 @@ class GeneWebParser: try: while 1: line = self.get_next_line() - if line == None: + if line is None: break if line == "": continue @@ -238,7 +238,7 @@ class GeneWebParser: rel_person = self.db.get_person_from_handle(self.current_relationship_person_handle) while 1: line = self.get_next_line() - if line == None or line == "end": + if line is None or line == "end": break if line == "": continue @@ -315,7 +315,7 @@ class GeneWebParser: return None while 1: line = self.get_next_line() - if line == None: + if line is None: break if line == "": continue @@ -384,7 +384,7 @@ class GeneWebParser: note_txt = "" while True: line = self.get_next_line() - if line == None: + if line is None: break fields = line.split(" ") @@ -529,7 +529,7 @@ class GeneWebParser: name.set_first_name(firstname) name.set_surname(surname) person.set_primary_name(name) - if person.get_gender() == gen.lib.Person.UNKNOWN and gender != None: + if person.get_gender() == gen.lib.Person.UNKNOWN and gender is not None: person.set_gender(gender) self.db.commit_person(person,self.trans) personDataRe = re.compile("^[kmes0-9<>~#\[({!].*$") diff --git a/src/plugins/ImportvCard.py b/src/plugins/ImportvCard.py index 1d7606777..7ca182795 100644 --- a/src/plugins/ImportvCard.py +++ b/src/plugins/ImportvCard.py @@ -107,7 +107,7 @@ class VCardParser: try: while 1: line = self.get_next_line() - if line == None: + if line is None: break if line == "": continue diff --git a/src/plugins/IndivComplete.py b/src/plugins/IndivComplete.py index 38830714c..030a5054f 100644 --- a/src/plugins/IndivComplete.py +++ b/src/plugins/IndivComplete.py @@ -83,7 +83,7 @@ class IndivCompleteReport(Report): def write_fact(self,event_ref): event = self.database.get_event_from_handle(event_ref.ref) - if event == None: + if event is None: return text = "" if event_ref.get_role() == gen.lib.EventRoleType.PRIMARY or \ diff --git a/src/plugins/MediaManager.py b/src/plugins/MediaManager.py index 74d1d2c94..11801160e 100644 --- a/src/plugins/MediaManager.py +++ b/src/plugins/MediaManager.py @@ -216,7 +216,7 @@ class MediaMan(Tool.Tool): self.batch_settings = ix box.show_all() else: - if self.batch_settings != None: + if self.batch_settings is not None: self.w.remove_page(self.settings_page) self.settings_page = None self.confirm_page -= 1 diff --git a/src/plugins/NarrativeWeb.py b/src/plugins/NarrativeWeb.py index 3a9c343e4..3c860fc94 100644 --- a/src/plugins/NarrativeWeb.py +++ b/src/plugins/NarrativeWeb.py @@ -1120,7 +1120,7 @@ class MediaPage(BasePage): if mime_type: note_only = False newpath = self.copy_source_file(handle, photo) - target_exists = newpath != None + target_exists = newpath is not None else: note_only = True target_exists = False @@ -1411,7 +1411,7 @@ class SurnameListPage(BasePage): def surname_link(self, of, fname, name, opt_val=None, up=False): url = self.report.build_url_fname_html(fname, 'srn', up) of.write('%s' % (url, name)) - if opt_val != None: + if opt_val is not None: of.write(' (%d)' % opt_val) of.write('') @@ -2540,7 +2540,7 @@ class NavWebReport(Report): def write_report(self): if not self.use_archive: dir_name = self.target_path - if dir_name == None: + if dir_name is None: dir_name = os.getcwd() elif not os.path.isdir(dir_name): parent_dir = os.path.dirname(dir_name) diff --git a/src/plugins/Query.py b/src/plugins/Query.py index dda73e8b9..cb2bf61e0 100644 --- a/src/plugins/Query.py +++ b/src/plugins/Query.py @@ -270,7 +270,7 @@ class DBI: else: raise AttributeError("unknown state: '%s'" % state) i += 1 - if self.table == None: + if self.table is None: raise AttributeError("malformed query: no table in '%s'\n" % self.query) def close(self): diff --git a/src/plugins/RelCalc.py b/src/plugins/RelCalc.py index b2f25296b..10aba4c27 100644 --- a/src/plugins/RelCalc.py +++ b/src/plugins/RelCalc.py @@ -180,7 +180,7 @@ class RelCalc(Tool.Tool, ManagedWindow.ManagedWindow): p2 = name_displayer.display(other_person) text = [] - if other_person == None: + if other_person is None: pass elif self.person.handle == other_person.handle: rstr = _("%s and %s are the same person.") % (p1, p2) diff --git a/src/plugins/ReorderIds.py b/src/plugins/ReorderIds.py index 51fb565bc..6378b3e56 100644 --- a/src/plugins/ReorderIds.py +++ b/src/plugins/ReorderIds.py @@ -186,7 +186,7 @@ class ReorderIds(Tool.BatchTool): newgramps_id = prefix % int(index) if newgramps_id == gramps_id: newids[newgramps_id] = gramps_id - elif find_from_id(newgramps_id) != None: + elif find_from_id(newgramps_id) is not None: dups.append(obj.get_handle()) else: obj.set_gramps_id(newgramps_id) diff --git a/src/plugins/TestcaseGenerator.py b/src/plugins/TestcaseGenerator.py index b371c1492..5a4731d64 100644 --- a/src/plugins/TestcaseGenerator.py +++ b/src/plugins/TestcaseGenerator.py @@ -625,7 +625,7 @@ class TestcaseGenerator(Tool.Tool): self.fill_object(np) # Gender - if gender == None: + if gender is None: gender = randint(0,1) if randint(0,10) == 1: # Set some persons to unknown gender np.set_gender(gen.lib.Person.UNKNOWN) diff --git a/src/plugins/TimeLine.py b/src/plugins/TimeLine.py index c0aac65a6..bfbd711e0 100644 --- a/src/plugins/TimeLine.py +++ b/src/plugins/TimeLine.py @@ -271,9 +271,9 @@ class TimeLine(Report): # on a decade. low -= 50 - ((high-low) % 50) - if low == None: + if low is None: low = high - if high == None: + if high is None: high = low return (low, high) diff --git a/src/plugins/WebCal.py b/src/plugins/WebCal.py index 05610f112..d4f4e420b 100644 --- a/src/plugins/WebCal.py +++ b/src/plugins/WebCal.py @@ -213,8 +213,8 @@ class WebCalReport(Report): if int(n.get_type()) == gen.lib.NameType.MARRIED: married_name = n # Now, decide which to use: - if maiden_name != None: - if married_name != None: + if maiden_name is not None: + if married_name is not None: first_name, family_name = married_name.get_first_name(), married_name.get_surname() call_name = married_name.get_call_name() else: @@ -224,7 +224,7 @@ class WebCalReport(Report): first_name, family_name = primary_name.get_first_name(), primary_name.get_surname() call_name = primary_name.get_call_name() # If they have a nickname use it - if call_name != None and call_name.strip() != "": + if call_name is not None and call_name.strip() != "": first_name = call_name.strip() else: # else just get the first name: first_name = first_name.strip() @@ -599,7 +599,7 @@ class WebCalReport(Report): birth_event = self.database.get_event_from_handle(birth_ref.ref) birth_date = birth_event.get_date_object() living = probably_alive(person, self.database, make_date(self.Year, 1, 1), 0) - if self.Birthday and birth_date != None and ((self.Alive and living) or not self.Alive): + if self.Birthday and birth_date is not None and ((self.Alive and living) or not self.Alive): year = birth_date.get_year() month = birth_date.get_month() day = birth_date.get_day() @@ -617,7 +617,7 @@ class WebCalReport(Report): if mother_handle == person_handle: if father_handle: father = self.database.get_person_from_handle(father_handle) - if father != None: + if father is not None: father_lastname = father.get_primary_name().get_surname() short_name = self.get_short_name(person, father_lastname) self.add_day_item("%s, %d" % (short_name, age), year, month, day) diff --git a/src/plugins/WriteFtree.py b/src/plugins/WriteFtree.py index 9d935272c..111655a94 100644 --- a/src/plugins/WriteFtree.py +++ b/src/plugins/WriteFtree.py @@ -154,7 +154,7 @@ class FtreeWriter: self.option_box.parse_options() self.restrict = self.option_box.restrict - if self.option_box.cfilter == None: + if self.option_box.cfilter is None: for p in self.db.get_person_handles(sort_handles=False): self.plist[p] = 1 else: diff --git a/src/plugins/WriteGeneWeb.py b/src/plugins/WriteGeneWeb.py index 4cc0e5fb7..a3ba47f64 100644 --- a/src/plugins/WriteGeneWeb.py +++ b/src/plugins/WriteGeneWeb.py @@ -188,7 +188,7 @@ class GeneWebWriter: self.images = self.option_box.images self.images_path = self.option_box.images_path - if self.option_box.cfilter == None: + if self.option_box.cfilter is None: for p in self.db.get_person_handles(sort_handles=False): self.plist[p] = 1 else: diff --git a/src/plugins/all_relations.py b/src/plugins/all_relations.py index 93d1c34b6..434ac56b5 100644 --- a/src/plugins/all_relations.py +++ b/src/plugins/all_relations.py @@ -219,7 +219,7 @@ class AllRelReport(): and self.rel_class.only_birth(relation[4]) distorig = len(relation[4]) distother = len(relation[2]) - if distorig == 1 and distother == 1 and not inlawa \ + if distorig == distother == 1 and not inlawa \ and not inlawb: rel_str = self.rel_class.get_sibling_relationship_string( self.rel_class.get_sibling_type( diff --git a/src/plugins/rel_cs.py b/src/plugins/rel_cs.py index d159d4703..5a27a9351 100644 --- a/src/plugins/rel_cs.py +++ b/src/plugins/rel_cs.py @@ -150,7 +150,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): Special cases: relation strings "", "undefined" and "spouse". """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): @@ -197,7 +197,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_nephew(firstRel-1),common) else: return (self.get_niece(firstRel-1),common) - elif firstRel == 2 and secondRel == 2: + elif firstRel == secondRel == 2: if other_person.get_gender() == gen.lib.Person.MALE: return ('vlastní bratranec',common) else: diff --git a/src/plugins/rel_da.py b/src/plugins/rel_da.py index 3e527204e..44a4ba323 100644 --- a/src/plugins/rel_da.py +++ b/src/plugins/rel_da.py @@ -167,7 +167,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): Special cases: relation strings "", "undefined" and "spouse". """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): diff --git a/src/plugins/rel_es.py b/src/plugins/rel_es.py index e03482ef7..9592fdbc5 100644 --- a/src/plugins/rel_es.py +++ b/src/plugins/rel_es.py @@ -256,7 +256,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): along with a list of common ancestors (typically father,mother) """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): @@ -303,7 +303,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_nephew(firstRel-1),common) else: return (self.get_niece(firstRel-1),common) - elif firstRel == 2 and secondRel == 2: + elif firstRel == secondRel == 2: if other_person.get_gender() == gen.lib.Person.MALE: return ('primo hermano',common) else: diff --git a/src/plugins/rel_fi.py b/src/plugins/rel_fi.py index a38dd60c0..d95afa57a 100644 --- a/src/plugins/rel_fi.py +++ b/src/plugins/rel_fi.py @@ -177,7 +177,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): Special cases: relation strings "", "undefined" and "spouse". """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): diff --git a/src/plugins/rel_hu.py b/src/plugins/rel_hu.py index f431875f2..c5bd343e2 100644 --- a/src/plugins/rel_hu.py +++ b/src/plugins/rel_hu.py @@ -261,7 +261,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): along with a list of common ancestors (typically father,mother) """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): diff --git a/src/plugins/rel_it.py b/src/plugins/rel_it.py index 3ab43edc8..d86f2d7e5 100644 --- a/src/plugins/rel_it.py +++ b/src/plugins/rel_it.py @@ -319,7 +319,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): along with a list of common ancestors (typically father,mother) """ - if orig_person == None: + if orig_person is None: return ("non definito",[]) if orig_person.get_handle() == other_person.get_handle(): diff --git a/src/plugins/rel_no.py b/src/plugins/rel_no.py index 69456ef07..442a66945 100644 --- a/src/plugins/rel_no.py +++ b/src/plugins/rel_no.py @@ -227,7 +227,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): Special cases: relation strings "", "undefined" and "spouse". """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): diff --git a/src/plugins/rel_pl.py b/src/plugins/rel_pl.py index ad784ca63..8e0bd81fb 100644 --- a/src/plugins/rel_pl.py +++ b/src/plugins/rel_pl.py @@ -545,7 +545,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): # b is the same person as a - if Ga == 0 and Gb == 0: + if Ga == Gb == 0: rel_str = 'ta sama osoba' elif Ga == 0: @@ -588,7 +588,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): rel_str = self.get_parent_unknown(Ga, inlaw) - elif Ga == 1 and Gb == 1: + elif Ga == Gb == 1: # rodzeństwo if gender_b == gen.lib.Person.MALE: if inlaw and not step: diff --git a/src/plugins/rel_pt.py b/src/plugins/rel_pt.py index 220356f4b..5c8e54c99 100644 --- a/src/plugins/rel_pt.py +++ b/src/plugins/rel_pt.py @@ -250,7 +250,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): along with a list of common ancestors (typically father,mother) """ - if orig_person == None: + if orig_person is None: return ("indefinido",[]) if orig_person.get_handle() == other_person.get_handle(): @@ -296,7 +296,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_nephew(firstRel-1),common) else: return (self.get_niece(firstRel-1),common) - elif firstRel == 2 and secondRel == 2: + elif firstRel == secondRel == 2: if other_person.get_gender() == gen.lib.Person.MALE: return ('primo irmão',common) else: diff --git a/src/plugins/rel_ru.py b/src/plugins/rel_ru.py index 8d3dad171..59d8dadd1 100644 --- a/src/plugins/rel_ru.py +++ b/src/plugins/rel_ru.py @@ -202,7 +202,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): Special cases: relation strings "", "undefined" and "spouse". """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): diff --git a/src/plugins/rel_sk.py b/src/plugins/rel_sk.py index 1c5fddc0d..f9721af6f 100644 --- a/src/plugins/rel_sk.py +++ b/src/plugins/rel_sk.py @@ -150,7 +150,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): Special cases: relation strings "", "undefined" and "spouse". """ - if orig_person == None: + if orig_person is None: return ("undefined",[]) if orig_person.get_handle() == other_person.get_handle(): @@ -197,7 +197,7 @@ class RelationshipCalculator(Relationship.RelationshipCalculator): return (self.get_nephew(firstRel-1),common) else: return (self.get_niece(firstRel-1),common) - elif firstRel == 2 and secondRel == 2: + elif firstRel == secondRel == 2: if other_person.get_gender() == gen.lib.Person.MALE: return ('vlastný bratranec',common) else: diff --git a/src/widgets/labels.py b/src/widgets/labels.py index 5084660a0..dace9fa07 100644 --- a/src/widgets/labels.py +++ b/src/widgets/labels.py @@ -72,7 +72,7 @@ def realize_cb(widget): class LinkLabel(gtk.EventBox): def __init__(self, label, func, handle, decoration=None): - if decoration == None: + if decoration is None: relation_display_theme = Config.get(Config.RELATION_DISPLAY_THEME) if relation_display_theme == "CLASSIC": decoration = 'underline="single"' diff --git a/src/widgets/monitoredwidgets.py b/src/widgets/monitoredwidgets.py index 246f6ac59..91d704bf5 100644 --- a/src/widgets/monitoredwidgets.py +++ b/src/widgets/monitoredwidgets.py @@ -352,7 +352,7 @@ class MonitoredDataType: i = ignore_values.index(key) except ValueError: i = None - if (not i==None) and (not ignore_values[i] == default) : + if (i is not None) and (not ignore_values[i] == default) : del map[key] self.sel = AutoComp.StandardCustomSelector(