Fixed pycodestyle E7 errors

This commit is contained in:
Veronica K. B. Olsen
2020-08-12 21:11:25 +02:00
parent 95ee2bf874
commit 72cb1ed60f
16 changed files with 38 additions and 36 deletions
+1 -1
View File
@@ -222,7 +222,7 @@ class NWIndex():
if len(self.textCounts[tHandle]) != 3:
self.indexBroken = True
except:
except Exception:
self.indexBroken = True
if self.indexBroken:
+5 -5
View File
@@ -130,7 +130,7 @@ class NWItem():
def _subPack(xParent, name, attrib=None, text=None, none=True):
"""Packs the values into an xml element.
"""
if not none and (text == None or text == "None"):
if not none and (text is None or text == "None"):
return None
xSub = etree.SubElement(xParent, name, attrib=attrib)
if text is not None:
@@ -233,18 +233,18 @@ class NWItem():
"""Save the expanded status of an item in the project tree.
"""
if isinstance(expState, str):
self.isExpanded = expState == str(True)
self.isExpanded = (expState == str(True))
else:
self.isExpanded = expState == True
self.isExpanded = (expState == True) # noqa
return
def setExported(self, expState):
"""Save the export flag.
"""
if isinstance(expState, str):
self.isExported = expState == str(True)
self.isExported = (expState == str(True))
else:
self.isExported = expState == True
self.isExported = (expState == True) # noqa
return
##
+3 -3
View File
@@ -153,15 +153,15 @@ class OptionState():
def setValue(self, setGroup, setName, setValue):
"""Saves a value, with a given group and name.
"""
if not setGroup in self.validMap:
if setGroup not in self.validMap:
logger.error("Unknown option group '%s'" % setGroup)
return False
if not setName in self.validMap[setGroup]:
if setName not in self.validMap[setGroup]:
logger.error("Unknown option name '%s'" % setName)
return False
if not setGroup in self.theState:
if setGroup not in self.theState:
self.theState[setGroup] = {}
self.theState[setGroup][setName] = setValue
+3 -2
View File
@@ -1243,7 +1243,8 @@ class NWProject():
for aValue in theValue:
if not isinstance(aValue, str):
aValue = str(aValue)
if aValue == "" and not allowNone: continue
if aValue == "" and not allowNone:
continue
xItem = etree.SubElement(xParent, theName)
xItem.text = aValue
return
@@ -1402,7 +1403,7 @@ class NWProject():
try:
rmdir(theData)
logger.info("Removed folder: %s" % theFolder)
except:
except Exception:
errList.append("Failed to remove: %s" % theFolder)
return errList
+2 -2
View File
@@ -149,7 +149,7 @@ class NWSpellEnchant(NWSpellCheck):
self.theDict = enchant.Dict(theLang)
self.spellLanguage = theLang
logger.debug("Enchant spell checking for language %s loaded" % theLang)
except:
except Exception:
logger.error("Failed to load enchant spell checking for language %s" % theLang)
self.theDict = NWSpellEnchantDummy()
self.spellLanguage = None
@@ -186,7 +186,7 @@ class NWSpellEnchant(NWSpellCheck):
for spTag, spProvider in enchant.list_dicts():
spName = "%s [%s]" % (self.expandLanguage(spTag), spProvider.name)
retList.append((spTag, spName))
except:
except Exception:
logger.error("Failed to list languages for enchant spell checking")
return retList
+2 -1
View File
@@ -78,7 +78,8 @@ def countWords(theText):
charCount += theLen
if countPara and prevEmpty:
paraCount += 1
prevEmpty = countPara == False
prevEmpty = not countPara
return charCount, wordCount, paraCount