Fixed pycodestyle E7 errors
This commit is contained in:
+2
-2
@@ -240,12 +240,12 @@ def main(sysArgs=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import PyQt5.QtSvg
|
import PyQt5.QtSvg
|
||||||
except:
|
except ImportError:
|
||||||
errorData.append("Python module 'PyQt5.QtSvg' is missing.")
|
errorData.append("Python module 'PyQt5.QtSvg' is missing.")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import lxml
|
import lxml
|
||||||
except:
|
except ImportError:
|
||||||
errorData.append("Python module 'lxml' is missing.")
|
errorData.append("Python module 'lxml' is missing.")
|
||||||
|
|
||||||
if errorData:
|
if errorData:
|
||||||
|
|||||||
+4
-4
@@ -38,7 +38,7 @@ def checkString(checkValue, defaultValue, allowNone=False):
|
|||||||
"""Check if a variable is a string or a none.
|
"""Check if a variable is a string or a none.
|
||||||
"""
|
"""
|
||||||
if allowNone:
|
if allowNone:
|
||||||
if checkValue == None:
|
if checkValue is None:
|
||||||
return None
|
return None
|
||||||
if checkValue == "None":
|
if checkValue == "None":
|
||||||
return None
|
return None
|
||||||
@@ -50,20 +50,20 @@ def checkInt(checkValue, defaultValue, allowNone=False):
|
|||||||
"""Check if a variable is an integer or a none.
|
"""Check if a variable is an integer or a none.
|
||||||
"""
|
"""
|
||||||
if allowNone:
|
if allowNone:
|
||||||
if checkValue == None:
|
if checkValue is None:
|
||||||
return None
|
return None
|
||||||
if checkValue == "None":
|
if checkValue == "None":
|
||||||
return None
|
return None
|
||||||
try:
|
try:
|
||||||
return int(checkValue)
|
return int(checkValue)
|
||||||
except:
|
except Exception:
|
||||||
return defaultValue
|
return defaultValue
|
||||||
|
|
||||||
def checkBool(checkValue, defaultValue, allowNone=False):
|
def checkBool(checkValue, defaultValue, allowNone=False):
|
||||||
"""Check if a variable is a boolean or a none.
|
"""Check if a variable is a boolean or a none.
|
||||||
"""
|
"""
|
||||||
if allowNone:
|
if allowNone:
|
||||||
if checkValue == None:
|
if checkValue is None:
|
||||||
return None
|
return None
|
||||||
if checkValue == "None":
|
if checkValue == "None":
|
||||||
return None
|
return None
|
||||||
|
|||||||
+3
-3
@@ -862,7 +862,7 @@ class Config:
|
|||||||
for i in range(listLen):
|
for i in range(listLen):
|
||||||
try:
|
try:
|
||||||
outData.append(castTo(inData[i]))
|
outData.append(castTo(inData[i]))
|
||||||
except:
|
except Exception:
|
||||||
outData.append(listDefault[i])
|
outData.append(listDefault[i])
|
||||||
return outData
|
return outData
|
||||||
|
|
||||||
@@ -905,13 +905,13 @@ class Config:
|
|||||||
import enchant
|
import enchant
|
||||||
self.hasEnchant = True
|
self.hasEnchant = True
|
||||||
logger.debug("Checking package 'pyenchant': Ok")
|
logger.debug("Checking package 'pyenchant': Ok")
|
||||||
except:
|
except Exception:
|
||||||
self.hasEnchant = False
|
self.hasEnchant = False
|
||||||
logger.debug("Checking package 'pyenchant': Missing")
|
logger.debug("Checking package 'pyenchant': Missing")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.hasAssistant = which("assistant")
|
self.hasAssistant = which("assistant")
|
||||||
except:
|
except Exception:
|
||||||
self.hasAssistant = False
|
self.hasAssistant = False
|
||||||
if self.hasAssistant:
|
if self.hasAssistant:
|
||||||
logger.debug("Checking executable 'assistant': Ok")
|
logger.debug("Checking executable 'assistant': Ok")
|
||||||
|
|||||||
+1
-1
@@ -222,7 +222,7 @@ class NWIndex():
|
|||||||
if len(self.textCounts[tHandle]) != 3:
|
if len(self.textCounts[tHandle]) != 3:
|
||||||
self.indexBroken = True
|
self.indexBroken = True
|
||||||
|
|
||||||
except:
|
except Exception:
|
||||||
self.indexBroken = True
|
self.indexBroken = True
|
||||||
|
|
||||||
if self.indexBroken:
|
if self.indexBroken:
|
||||||
|
|||||||
+5
-5
@@ -130,7 +130,7 @@ class NWItem():
|
|||||||
def _subPack(xParent, name, attrib=None, text=None, none=True):
|
def _subPack(xParent, name, attrib=None, text=None, none=True):
|
||||||
"""Packs the values into an xml element.
|
"""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
|
return None
|
||||||
xSub = etree.SubElement(xParent, name, attrib=attrib)
|
xSub = etree.SubElement(xParent, name, attrib=attrib)
|
||||||
if text is not None:
|
if text is not None:
|
||||||
@@ -233,18 +233,18 @@ class NWItem():
|
|||||||
"""Save the expanded status of an item in the project tree.
|
"""Save the expanded status of an item in the project tree.
|
||||||
"""
|
"""
|
||||||
if isinstance(expState, str):
|
if isinstance(expState, str):
|
||||||
self.isExpanded = expState == str(True)
|
self.isExpanded = (expState == str(True))
|
||||||
else:
|
else:
|
||||||
self.isExpanded = expState == True
|
self.isExpanded = (expState == True) # noqa
|
||||||
return
|
return
|
||||||
|
|
||||||
def setExported(self, expState):
|
def setExported(self, expState):
|
||||||
"""Save the export flag.
|
"""Save the export flag.
|
||||||
"""
|
"""
|
||||||
if isinstance(expState, str):
|
if isinstance(expState, str):
|
||||||
self.isExported = expState == str(True)
|
self.isExported = (expState == str(True))
|
||||||
else:
|
else:
|
||||||
self.isExported = expState == True
|
self.isExported = (expState == True) # noqa
|
||||||
return
|
return
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|||||||
+3
-3
@@ -153,15 +153,15 @@ class OptionState():
|
|||||||
def setValue(self, setGroup, setName, setValue):
|
def setValue(self, setGroup, setName, setValue):
|
||||||
"""Saves a value, with a given group and name.
|
"""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)
|
logger.error("Unknown option group '%s'" % setGroup)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not setName in self.validMap[setGroup]:
|
if setName not in self.validMap[setGroup]:
|
||||||
logger.error("Unknown option name '%s'" % setName)
|
logger.error("Unknown option name '%s'" % setName)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not setGroup in self.theState:
|
if setGroup not in self.theState:
|
||||||
self.theState[setGroup] = {}
|
self.theState[setGroup] = {}
|
||||||
|
|
||||||
self.theState[setGroup][setName] = setValue
|
self.theState[setGroup][setName] = setValue
|
||||||
|
|||||||
+3
-2
@@ -1243,7 +1243,8 @@ class NWProject():
|
|||||||
for aValue in theValue:
|
for aValue in theValue:
|
||||||
if not isinstance(aValue, str):
|
if not isinstance(aValue, str):
|
||||||
aValue = str(aValue)
|
aValue = str(aValue)
|
||||||
if aValue == "" and not allowNone: continue
|
if aValue == "" and not allowNone:
|
||||||
|
continue
|
||||||
xItem = etree.SubElement(xParent, theName)
|
xItem = etree.SubElement(xParent, theName)
|
||||||
xItem.text = aValue
|
xItem.text = aValue
|
||||||
return
|
return
|
||||||
@@ -1402,7 +1403,7 @@ class NWProject():
|
|||||||
try:
|
try:
|
||||||
rmdir(theData)
|
rmdir(theData)
|
||||||
logger.info("Removed folder: %s" % theFolder)
|
logger.info("Removed folder: %s" % theFolder)
|
||||||
except:
|
except Exception:
|
||||||
errList.append("Failed to remove: %s" % theFolder)
|
errList.append("Failed to remove: %s" % theFolder)
|
||||||
|
|
||||||
return errList
|
return errList
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ class NWSpellEnchant(NWSpellCheck):
|
|||||||
self.theDict = enchant.Dict(theLang)
|
self.theDict = enchant.Dict(theLang)
|
||||||
self.spellLanguage = theLang
|
self.spellLanguage = theLang
|
||||||
logger.debug("Enchant spell checking for language %s loaded" % 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)
|
logger.error("Failed to load enchant spell checking for language %s" % theLang)
|
||||||
self.theDict = NWSpellEnchantDummy()
|
self.theDict = NWSpellEnchantDummy()
|
||||||
self.spellLanguage = None
|
self.spellLanguage = None
|
||||||
@@ -186,7 +186,7 @@ class NWSpellEnchant(NWSpellCheck):
|
|||||||
for spTag, spProvider in enchant.list_dicts():
|
for spTag, spProvider in enchant.list_dicts():
|
||||||
spName = "%s [%s]" % (self.expandLanguage(spTag), spProvider.name)
|
spName = "%s [%s]" % (self.expandLanguage(spTag), spProvider.name)
|
||||||
retList.append((spTag, spName))
|
retList.append((spTag, spName))
|
||||||
except:
|
except Exception:
|
||||||
logger.error("Failed to list languages for enchant spell checking")
|
logger.error("Failed to list languages for enchant spell checking")
|
||||||
return retList
|
return retList
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -78,7 +78,8 @@ def countWords(theText):
|
|||||||
charCount += theLen
|
charCount += theLen
|
||||||
if countPara and prevEmpty:
|
if countPara and prevEmpty:
|
||||||
paraCount += 1
|
paraCount += 1
|
||||||
prevEmpty = countPara == False
|
|
||||||
|
prevEmpty = not countPara
|
||||||
|
|
||||||
return charCount, wordCount, paraCount
|
return charCount, wordCount, paraCount
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1272,7 +1272,7 @@ class GuiDocEditor(QTextEdit):
|
|||||||
try:
|
try:
|
||||||
isFind = self.lastFind[0] == theCursor.selectionStart()
|
isFind = self.lastFind[0] == theCursor.selectionStart()
|
||||||
isFind &= self.lastFind[1] == theCursor.selectionEnd()
|
isFind &= self.lastFind[1] == theCursor.selectionEnd()
|
||||||
except:
|
except Exception:
|
||||||
isFind = False
|
isFind = False
|
||||||
|
|
||||||
if isFind:
|
if isFind:
|
||||||
|
|||||||
+4
-4
@@ -193,7 +193,7 @@ class GuiOutline(QTreeWidget):
|
|||||||
tHandle = tItem.data(self.colIndex[nwOutline.TITLE], Qt.UserRole)
|
tHandle = tItem.data(self.colIndex[nwOutline.TITLE], Qt.UserRole)
|
||||||
try:
|
try:
|
||||||
tLine = int(tItem.text(self.colIndex[nwOutline.LINE]))
|
tLine = int(tItem.text(self.colIndex[nwOutline.LINE]))
|
||||||
except:
|
except Exception:
|
||||||
tLine = 1
|
tLine = 1
|
||||||
|
|
||||||
logger.verbose("User selected entry with handle %s on line %s" % (tHandle, tLine))
|
logger.verbose("User selected entry with handle %s on line %s" % (tHandle, tLine))
|
||||||
@@ -254,7 +254,7 @@ class GuiOutline(QTreeWidget):
|
|||||||
for hName in tempOrder:
|
for hName in tempOrder:
|
||||||
try:
|
try:
|
||||||
treeOrder.append(nwOutline[hName])
|
treeOrder.append(nwOutline[hName])
|
||||||
except:
|
except Exception:
|
||||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||||
|
|
||||||
# Add columns that was not in the file to the treeOrder array.
|
# Add columns that was not in the file to the treeOrder array.
|
||||||
@@ -276,14 +276,14 @@ class GuiOutline(QTreeWidget):
|
|||||||
for hName in tmpWidth:
|
for hName in tmpWidth:
|
||||||
try:
|
try:
|
||||||
self.colWidth[nwOutline[hName]] = self.mainConf.pxInt(tmpWidth[hName])
|
self.colWidth[nwOutline[hName]] = self.mainConf.pxInt(tmpWidth[hName])
|
||||||
except:
|
except Exception:
|
||||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||||
|
|
||||||
tmpHidden = self.optState.getValue("GuiOutline", "columnHidden", {})
|
tmpHidden = self.optState.getValue("GuiOutline", "columnHidden", {})
|
||||||
for hName in tmpHidden:
|
for hName in tmpHidden:
|
||||||
try:
|
try:
|
||||||
self.colHidden[nwOutline[hName]] = tmpHidden[hName]
|
self.colHidden[nwOutline[hName]] = tmpHidden[hName]
|
||||||
except:
|
except Exception:
|
||||||
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
logger.warning("Ignored unknown outline column '%s'" % str(hName))
|
||||||
|
|
||||||
self.headerMenu.setHiddenState(self.colHidden)
|
self.headerMenu.setHiddenState(self.colHidden)
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ class GuiOutlineDetails(QScrollArea):
|
|||||||
nwItem = self.theProject.projTree[tHandle]
|
nwItem = self.theProject.projTree[tHandle]
|
||||||
novIdx = self.theIndex.novelIndex[tHandle][sTitle]
|
novIdx = self.theIndex.novelIndex[tHandle][sTitle]
|
||||||
theRefs = self.theIndex.getReferences(tHandle, sTitle)
|
theRefs = self.theIndex.getReferences(tHandle, sTitle)
|
||||||
except:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if novIdx["level"] in self.LVL_MAP:
|
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:
|
if nHandle is not None and nHandle in self.theMap:
|
||||||
try:
|
try:
|
||||||
byIndex = self.theMap[pHandle].indexOfChild(self.theMap[nHandle])
|
byIndex = self.theMap[pHandle].indexOfChild(self.theMap[nHandle])
|
||||||
except:
|
except Exception:
|
||||||
logger.error("Failed to get index of item with handle %s" % nHandle)
|
logger.error("Failed to get index of item with handle %s" % nHandle)
|
||||||
if byIndex >= 0:
|
if byIndex >= 0:
|
||||||
self.theMap[pHandle].insertChild(byIndex+1, newItem)
|
self.theMap[pHandle].insertChild(byIndex+1, newItem)
|
||||||
|
|||||||
+2
-2
@@ -242,9 +242,9 @@ class StatusLED(QAbstractButton):
|
|||||||
"""
|
"""
|
||||||
if theState is None:
|
if theState is None:
|
||||||
self._theCol = self.colNone
|
self._theCol = self.colNone
|
||||||
elif theState == True:
|
elif theState:
|
||||||
self._theCol = self.colTrue
|
self._theCol = self.colTrue
|
||||||
elif theState == False:
|
elif not theState:
|
||||||
self._theCol = self.colFalse
|
self._theCol = self.colFalse
|
||||||
else:
|
else:
|
||||||
self._theCol = self.colNone
|
self._theCol = self.colNone
|
||||||
|
|||||||
+3
-3
@@ -182,7 +182,7 @@ class GuiTheme:
|
|||||||
for fontFam in listdir(fontAssets):
|
for fontFam in listdir(fontAssets):
|
||||||
fontDir = path.join(fontAssets, fontFam)
|
fontDir = path.join(fontAssets, fontFam)
|
||||||
if path.isdir(fontDir):
|
if path.isdir(fontDir):
|
||||||
if not fontFam in self.guiFontDB.families():
|
if fontFam not in self.guiFontDB.families():
|
||||||
for fontFile in listdir(fontDir):
|
for fontFile in listdir(fontDir):
|
||||||
ttfFile = path.join(fontDir, fontFile)
|
ttfFile = path.join(fontDir, fontFile)
|
||||||
if path.isfile(ttfFile) and fontFile.endswith(".ttf"):
|
if path.isfile(ttfFile) and fontFile.endswith(".ttf"):
|
||||||
@@ -438,7 +438,7 @@ class GuiTheme:
|
|||||||
outData.append(int(inData[0]))
|
outData.append(int(inData[0]))
|
||||||
outData.append(int(inData[1]))
|
outData.append(int(inData[1]))
|
||||||
outData.append(int(inData[2]))
|
outData.append(int(inData[2]))
|
||||||
except:
|
except Exception:
|
||||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||||
outData = [0, 0, 0]
|
outData = [0, 0, 0]
|
||||||
else:
|
else:
|
||||||
@@ -456,7 +456,7 @@ class GuiTheme:
|
|||||||
readCol.append(int(inData[0]))
|
readCol.append(int(inData[0]))
|
||||||
readCol.append(int(inData[1]))
|
readCol.append(int(inData[1]))
|
||||||
readCol.append(int(inData[2]))
|
readCol.append(int(inData[2]))
|
||||||
except:
|
except Exception:
|
||||||
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
logger.error("Could not load theme colours for '%s' from config file" % cnfName)
|
||||||
return
|
return
|
||||||
if len(readCol) == 3:
|
if len(readCol) == 3:
|
||||||
|
|||||||
+1
-1
@@ -391,7 +391,7 @@ class GuiMain(QMainWindow):
|
|||||||
int(self.theProject.lockedBy[3])
|
int(self.theProject.lockedBy[3])
|
||||||
).strftime("%x %X")
|
).strftime("%x %X")
|
||||||
)
|
)
|
||||||
except:
|
except Exception:
|
||||||
lockDetails = ""
|
lockDetails = ""
|
||||||
|
|
||||||
msgBox = QMessageBox()
|
msgBox = QMessageBox()
|
||||||
|
|||||||
Reference in New Issue
Block a user