Merge pull request #86 from tecknicaltom/various_python_issues

Various python issues
This commit is contained in:
Nick Hall 2015-12-31 21:15:46 +00:00
commit e67832d384
18 changed files with 22 additions and 36 deletions

View File

@ -108,7 +108,6 @@ class FilterList(object):
the_file.close()
except (IOError, OSError):
print("IO/OSError in _filterlist.py")
pass
except SAXParseException:
print("Parser error")

View File

@ -55,5 +55,4 @@ class RegExpName(Rule):
name.title, name.nick, name.famnick, name.call]:
if self.match_substring(0, field):
return True
else:
return False
return False

View File

@ -57,5 +57,4 @@ class SearchName(Rule):
name.title, name.nick, name.famnick, name.call]:
if src and field.upper().find(src) != -1:
return True
else:
return False
return False

View File

@ -692,8 +692,7 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
for attr in self.attribute_list:
if int(attr.type) == AttributeType.NICKNAME:
return attr.get_value()
else:
return ''
return ''
def set_gender(self, gender) :
"""
@ -743,9 +742,9 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
for self.birth_ref_index, ref in enumerate(self.event_ref_list):
if event_ref.is_equal(ref):
return # Note: self.birth_ref_index already set
else:
self.event_ref_list.append(event_ref)
self.birth_ref_index = len(self.event_ref_list)-1
self.event_ref_list.append(event_ref)
self.birth_ref_index = len(self.event_ref_list)-1
def set_death_ref(self, event_ref):
"""
@ -768,9 +767,9 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
for self.death_ref_index, ref in enumerate(self.event_ref_list):
if event_ref.is_equal(ref):
return # Note: self.death_ref_index already set
else:
self.event_ref_list.append(event_ref)
self.death_ref_index = len(self.event_ref_list)-1
self.event_ref_list.append(event_ref)
self.death_ref_index = len(self.event_ref_list)-1
def get_birth_ref(self):
"""

View File

@ -214,7 +214,7 @@ def available_updates():
fp = urlopen_maybe_no_check_cert(URL)
except Exception as err: # some error
LOG.warning("Failed to open addon metadata for {lang} {url}: {err}".
format(lang=lang, url=URL, err=err))
format(lang=lang, url=URL, err=err))
fp = None
if fp and fp.getcode() == 200: # ok
break

View File

@ -295,7 +295,7 @@ class CallbackManager(object):
unconnect a signal from the database if it is already connected
"""
oldcall, oldconnectkey = self.__callbacks[signal]
if not oldconnectkey is None:
if oldconnectkey is not None:
self.database.disconnect(oldconnectkey)
def add_db_signal(self, name, callback):

View File

@ -425,7 +425,6 @@ class ODSTab(TabbedDoc):
errmsg = "%s\n%s" % (_("Could not create %s") % self.styles_xml, msg)
raise ReportError(errmsg)
except:
pass
raise ReportError(_("Could not create %s") % self.styles_xml)
self.f = open(self.styles_xml,"w")
@ -460,7 +459,6 @@ class ODSTab(TabbedDoc):
errmsg = "%s\n%s" % (_("Could not create %s") % self.manifest_xml, msg)
raise ReportError(errmsg)
except:
pass
raise ReportError(_("Could not create %s") % self.manifest_xml)
self.f = open(self.manifest_xml,"w")
@ -476,7 +474,6 @@ class ODSTab(TabbedDoc):
errmsg = "%s\n%s" % (_("Could not create %s") % self.meta_xml, msg)
raise ReportError(errmsg)
except:
pass
raise ReportError(_("Could not create %s") % self.meta_xml)
self.f = open(self.meta_xml,"w")
@ -499,7 +496,6 @@ class ODSTab(TabbedDoc):
errmsg = "%s\n%s" % (_("Could not create %s") % self.mimetype, msg)
raise ReportError(errmsg)
except:
pass
raise ReportError(_("Could not create %s") % self.mimetype)
self.f = open(self.mimetype,"w")

View File

@ -296,8 +296,8 @@ class RecentDocsMenu(object):
mitem.show()
new_menu.append(mitem)
except RuntimeError:
# ignore no longer existing files
_LOG.info("Ignoring the RecentItem %s (%s)" % (title, filename))
pass # ignore no longer existing files
count += 1
buf.write(_RCT_BTM)

View File

@ -581,7 +581,7 @@ class EmbeddedList(ButtonTab):
self.tree.set_model(self.model)
#reset previous select
if not selectedpath is None:
if selectedpath is not None:
self.selection.select_path(selectedpath)
#self.selection.select_path(node)
self._set_label()

View File

@ -413,5 +413,5 @@ class EventEmbedList(DbGUIElement, GroupEmbeddedList):
@type prebuildpath: tree path
"""
self.tree.expand_all()
if not prebuildpath is None:
if prebuildpath is not None:
self.selection.select_path(prebuildpath)

View File

@ -219,5 +219,5 @@ class NameEmbedList(GroupEmbeddedList):
@type prebuildpath: tree path
"""
self.tree.expand_all()
if not prebuildpath is None:
if prebuildpath is not None:
self.selection.select_path(prebuildpath)

View File

@ -214,5 +214,5 @@ class Glade(Gtk.Builder):
return obj
if hasattr(obj, 'get_children'):
queue += obj.get_children()
else:
return None
return None

View File

@ -549,8 +549,7 @@ class ExportAssistant(Gtk.Assistant, ManagedWindow) :
button = self.format_buttons[ix]
if button.get_active():
return ix
else:
return 0
return 0
def suggest_filename(self):
"""Prepare suggested filename and set it in the file chooser."""

View File

@ -1238,7 +1238,7 @@ class BaseReader(object):
self.ifile.seek(0)
def readline(self):
raise NotImplemented
raise NotImplementedError()
def report_error(self, problem, line):
line = line.rstrip('\n\r')

View File

@ -404,7 +404,6 @@ class GeoGraphyView(OsmGps, NavigationView):
path = "%s%c%s" % ( config.get('geography.path'), os.sep, the_map )
shutil.rmtree(path)
pass
def add_specific_menu(self, menu, event, lat, lon):
"""
@ -1110,7 +1109,6 @@ class GeoGraphyView(OsmGps, NavigationView):
else:
config.set("geography.lock", True)
self.lock = config.get("geography.lock")
pass
def config_crosshair(self, client, cnxn_id, entry, data):
"""
@ -1121,7 +1119,6 @@ class GeoGraphyView(OsmGps, NavigationView):
else:
config.set("geography.show_cross", True)
self.set_crosshair(config.get("geography.show_cross"))
pass
def specific_options(self, configdialog):
"""

View File

@ -234,7 +234,7 @@ class AllRelReport():
relation[4], relation[2],
only_birth = birth,
in_law_a = inlawa, in_law_b = inlawb)
if not skip_list_text is None:
if skip_list_text is not None:
if rel_str in skip_list_text:
skip_list.append(count)
else:

View File

@ -275,8 +275,8 @@ class SelectionPage(Gtk.Box):
button = self.batch_op_buttons[index]
if button.get_active():
return index
else:
return 0
return 0
class SettingsPage(Gtk.Box):
"""

View File

@ -3371,7 +3371,6 @@ class PlacePages(BasePage):
for place_handle in self.report.obj_dict[Place]:
step()
self.PlacePage(self.report, title, place_handle)
pass
def PlaceListPage(self, report, title, place_handles):
self.dbase_ = report.database
@ -6613,7 +6612,6 @@ class RepositoryPages(BasePage):
def __init__(self, report):
self.repos_dict = defaultdict(set)
self.report = report
pass
def display_pages(self, title):
"""