Fixed pycodestyle E7 errors
This commit is contained in:
+2
-2
@@ -240,12 +240,12 @@ def main(sysArgs=None):
|
||||
|
||||
try:
|
||||
import PyQt5.QtSvg
|
||||
except:
|
||||
except ImportError:
|
||||
errorData.append("Python module 'PyQt5.QtSvg' is missing.")
|
||||
|
||||
try:
|
||||
import lxml
|
||||
except:
|
||||
except ImportError:
|
||||
errorData.append("Python module 'lxml' is missing.")
|
||||
|
||||
if errorData:
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ def checkString(checkValue, defaultValue, allowNone=False):
|
||||
"""Check if a variable is a string or a none.
|
||||
"""
|
||||
if allowNone:
|
||||
if checkValue == None:
|
||||
if checkValue is None:
|
||||
return None
|
||||
if checkValue == "None":
|
||||
return None
|
||||
@@ -50,20 +50,20 @@ def checkInt(checkValue, defaultValue, allowNone=False):
|
||||
"""Check if a variable is an integer or a none.
|
||||
"""
|
||||
if allowNone:
|
||||
if checkValue == None:
|
||||
if checkValue is None:
|
||||
return None
|
||||
if checkValue == "None":
|
||||
return None
|
||||
try:
|
||||
return int(checkValue)
|
||||
except:
|
||||
except Exception:
|
||||
return defaultValue
|
||||
|
||||
def checkBool(checkValue, defaultValue, allowNone=False):
|
||||
"""Check if a variable is a boolean or a none.
|
||||
"""
|
||||
if allowNone:
|
||||
if checkValue == None:
|
||||
if checkValue is None:
|
||||
return None
|
||||
if checkValue == "None":
|
||||
return None
|
||||
|
||||
+3
-3
@@ -862,7 +862,7 @@ class Config:
|
||||
for i in range(listLen):
|
||||
try:
|
||||
outData.append(castTo(inData[i]))
|
||||
except:
|
||||
except Exception:
|
||||
outData.append(listDefault[i])
|
||||
return outData
|
||||
|
||||
@@ -905,13 +905,13 @@ class Config:
|
||||
import enchant
|
||||
self.hasEnchant = True
|
||||
logger.debug("Checking package 'pyenchant': Ok")
|
||||
except:
|
||||
except Exception:
|
||||
self.hasEnchant = False
|
||||
logger.debug("Checking package 'pyenchant': Missing")
|
||||
|
||||
try:
|
||||
self.hasAssistant = which("assistant")
|
||||
except:
|
||||
except Exception:
|
||||
self.hasAssistant = False
|
||||
if self.hasAssistant:
|
||||
logger.debug("Checking executable 'assistant': Ok")
|
||||
|
||||
+1
-1
@@ -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
@@ -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
@@ -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
@@ -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
|
||||
|
||||
@@ -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
@@ -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
|
||||
|
||||
|
||||
+1
-1
@@ -1272,7 +1272,7 @@ class GuiDocEditor(QTextEdit):
|
||||
try:
|
||||
isFind = self.lastFind[0] == theCursor.selectionStart()
|
||||
isFind &= self.lastFind[1] == theCursor.selectionEnd()
|
||||
except:
|
||||
except Exception:
|
||||
isFind = False
|
||||
|
||||
if isFind:
|
||||
|
||||
+4
-4
@@ -193,7 +193,7 @@ class GuiOutline(QTreeWidget):
|
||||
tHandle = tItem.data(self.colIndex[nwOutline.TITLE], Qt.UserRole)
|
||||
try:
|
||||
tLine = int(tItem.text(self.colIndex[nwOutline.LINE]))
|
||||
except:
|
||||
except Exception:
|
||||
tLine = 1
|
||||
|
||||
logger.verbose("User selected entry with handle %s on line %s" % (tHandle, tLine))
|
||||
@@ -254,7 +254,7 @@ class GuiOutline(QTreeWidget):
|
||||
for hName in tempOrder:
|
||||
try:
|
||||
treeOrder.append(nwOutline[hName])
|
||||
except:
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||
|
||||
# Add columns that was not in the file to the treeOrder array.
|
||||
@@ -276,14 +276,14 @@ class GuiOutline(QTreeWidget):
|
||||
for hName in tmpWidth:
|
||||
try:
|
||||
self.colWidth[nwOutline[hName]] = self.mainConf.pxInt(tmpWidth[hName])
|
||||
except:
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||
|
||||
tmpHidden = self.optState.getValue("GuiOutline", "columnHidden", {})
|
||||
for hName in tmpHidden:
|
||||
try:
|
||||
self.colHidden[nwOutline[hName]] = tmpHidden[hName]
|
||||
except:
|
||||
except Exception:
|
||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||
|
||||
self.headerMenu.setHiddenState(self.colHidden)
|
||||
|
||||
@@ -237,7 +237,7 @@ class GuiOutlineDetails(QScrollArea):
|
||||
nwItem = self.theProject.projTree[tHandle]
|
||||
novIdx = self.theIndex.novelIndex[tHandle][sTitle]
|
||||
theRefs = self.theIndex.getReferences(tHandle, sTitle)
|
||||
except:
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
if novIdx["level"] in self.LVL_MAP:
|
||||
|
||||
+1
-1
@@ -756,7 +756,7 @@ class GuiProjectTree(QTreeWidget):
|
||||
if nHandle is not None and nHandle in self.theMap:
|
||||
try:
|
||||
byIndex = self.theMap[pHandle].indexOfChild(self.theMap[nHandle])
|
||||
except:
|
||||
except Exception:
|
||||
logger.error("Failed to get index of item with handle %s" % nHandle)
|
||||
if byIndex >= 0:
|
||||
self.theMap[pHandle].insertChild(byIndex+1, newItem)
|
||||
|
||||
+2
-2
@@ -242,9 +242,9 @@ class StatusLED(QAbstractButton):
|
||||
"""
|
||||
if theState is None:
|
||||
self._theCol = self.colNone
|
||||
elif theState == True:
|
||||
elif theState:
|
||||
self._theCol = self.colTrue
|
||||
elif theState == False:
|
||||
elif not theState:
|
||||
self._theCol = self.colFalse
|
||||
else:
|
||||
self._theCol = self.colNone
|
||||
|
||||
+3
-3
@@ -182,7 +182,7 @@ class GuiTheme:
|
||||
for fontFam in listdir(fontAssets):
|
||||
fontDir = path.join(fontAssets, fontFam)
|
||||
if path.isdir(fontDir):
|
||||
if not fontFam in self.guiFontDB.families():
|
||||
if fontFam not in self.guiFontDB.families():
|
||||
for fontFile in listdir(fontDir):
|
||||
ttfFile = path.join(fontDir, fontFile)
|
||||
if path.isfile(ttfFile) and fontFile.endswith(".ttf"):
|
||||
@@ -438,7 +438,7 @@ class GuiTheme:
|
||||
outData.append(int(inData[0]))
|
||||
outData.append(int(inData[1]))
|
||||
outData.append(int(inData[2]))
|
||||
except:
|
||||
except Exception:
|
||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||
outData = [0, 0, 0]
|
||||
else:
|
||||
@@ -456,7 +456,7 @@ class GuiTheme:
|
||||
readCol.append(int(inData[0]))
|
||||
readCol.append(int(inData[1]))
|
||||
readCol.append(int(inData[2]))
|
||||
except:
|
||||
except Exception:
|
||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||
return
|
||||
if len(readCol) == 3:
|
||||
|
||||
+1
-1
@@ -391,7 +391,7 @@ class GuiMain(QMainWindow):
|
||||
int(self.theProject.lockedBy[3])
|
||||
).strftime("%x %X")
|
||||
)
|
||||
except:
|
||||
except Exception:
|
||||
lockDetails = ""
|
||||
|
||||
msgBox = QMessageBox()
|
||||
|
||||
Reference in New Issue
Block a user