Fixed pycodestyle E231 errors

This commit is contained in:
Veronica K. B. Olsen
2020-08-12 20:51:22 +02:00
parent 28ab689dab
commit 95ee2bf874
25 changed files with 162 additions and 162 deletions
+4 -4
View File
@@ -153,7 +153,7 @@ def main(sysArgs=None):
# Parse Options # Parse Options
try: try:
inOpts, inRemain = getopt.getopt(sysArgs,shortOpt,longOpt) inOpts, inRemain = getopt.getopt(sysArgs, shortOpt, longOpt)
except getopt.GetoptError as E: except getopt.GetoptError as E:
print(helpMsg) print(helpMsg)
print("ERROR: %s" % str(E)) print("ERROR: %s" % str(E))
@@ -163,7 +163,7 @@ def main(sysArgs=None):
cmdOpen = inRemain[0] cmdOpen = inRemain[0]
for inOpt, inArg in inOpts: for inOpt, inArg in inOpts:
if inOpt in ("-h","--help"): if inOpt in ("-h", "--help"):
print(helpMsg) print(helpMsg)
sys.exit() sys.exit()
elif inOpt in ("-v", "--version"): elif inOpt in ("-v", "--version"):
@@ -179,7 +179,7 @@ def main(sysArgs=None):
elif inOpt == "--logfile": elif inOpt == "--logfile":
logFile = inArg logFile = inArg
toFile = True toFile = True
elif inOpt in ("-q","--quiet"): elif inOpt in ("-q", "--quiet"):
toStd = False toStd = False
elif inOpt == "--verbose": elif inOpt == "--verbose":
debugLevel = VERBOSE debugLevel = VERBOSE
@@ -205,7 +205,7 @@ def main(sysArgs=None):
if path.isfile(logFile+".bak"): if path.isfile(logFile+".bak"):
remove(logFile+".bak") remove(logFile+".bak")
if path.isfile(logFile): if path.isfile(logFile):
rename(logFile,logFile+".bak") rename(logFile, logFile+".bak")
fHandle = logging.FileHandler(logFile) fHandle = logging.FileHandler(logFile)
fHandle.setLevel(debugLevel) fHandle.setLevel(debugLevel)
+8 -8
View File
@@ -42,7 +42,7 @@ def checkString(checkValue, defaultValue, allowNone=False):
return None return None
if checkValue == "None": if checkValue == "None":
return None return None
if isinstance(checkValue,str): if isinstance(checkValue, str):
return str(checkValue) return str(checkValue)
return defaultValue return defaultValue
@@ -109,7 +109,7 @@ def colRange(rgbStart, rgbEnd, nStep):
elif nStep == 2: elif nStep == 2:
return [rgbStart, rgbEnd] return [rgbStart, rgbEnd]
dC = [0,0,0] dC = [0, 0, 0]
for c in range(3): for c in range(3):
cA = rgbStart[c] cA = rgbStart[c]
cB = rgbEnd[c] cB = rgbEnd[c]
@@ -139,11 +139,11 @@ def formatInt(theInt):
theVal /= 1000.0 theVal /= 1000.0
if theVal < 1000.0: if theVal < 1000.0:
if theVal < 10.0: if theVal < 10.0:
return "%4.2f%s" % (theVal,pF) return "%4.2f%s" % (theVal, pF)
elif theVal < 100.0: elif theVal < 100.0:
return "%4.1f%s" % (theVal,pF) return "%4.1f%s" % (theVal, pF)
else: else:
return "%3.0f%s" % (theVal,pF) return "%3.0f%s" % (theVal, pF)
return "%d" % theInt return "%d" % theInt
@@ -169,11 +169,11 @@ def splitVersionNumber(vString):
nBits = len(vBits) nBits = len(vBits)
if nBits > 0: if nBits > 0:
vMajor = checkInt(vBits[0],0) vMajor = checkInt(vBits[0], 0)
if nBits > 1: if nBits > 1:
vMinor = checkInt(vBits[1],0) vMinor = checkInt(vBits[1], 0)
if nBits > 2: if nBits > 2:
vPatch = checkInt(vBits[2],0) vPatch = checkInt(vBits[2], 0)
vInt = vMajor*10000 + vMinor*100 + vPatch vInt = vMajor*10000 + vMinor*100 + vPatch
+61 -61
View File
@@ -260,12 +260,12 @@ class Config:
self.homePath = path.expanduser("~") self.homePath = path.expanduser("~")
self.lastPath = self.homePath self.lastPath = self.homePath
self.appPath = getattr(sys, "_MEIPASS", path.abspath(path.dirname(__file__))) self.appPath = getattr(sys, "_MEIPASS", path.abspath(path.dirname(__file__)))
self.appRoot = path.join(self.appPath,path.pardir) self.appRoot = path.join(self.appPath, path.pardir)
self.assetPath = path.join(self.appPath,"assets") self.assetPath = path.join(self.appPath, "assets")
self.themeRoot = path.join(self.assetPath,"themes") self.themeRoot = path.join(self.assetPath, "themes")
self.graphPath = path.join(self.assetPath,"graphics") self.graphPath = path.join(self.assetPath, "graphics")
self.dictPath = path.join(self.assetPath,"dict") self.dictPath = path.join(self.assetPath, "dict")
self.iconPath = path.join(self.assetPath,"icons") self.iconPath = path.join(self.assetPath, "icons")
self.appIcon = path.join(self.iconPath, "novelwriter.svg") self.appIcon = path.join(self.iconPath, "novelwriter.svg")
logger.verbose("App path: %s" % self.appPath) logger.verbose("App path: %s" % self.appPath)
@@ -549,85 +549,85 @@ class Config:
## Main ## Main
cnfSec = "Main" cnfSec = "Main"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"timestamp", formatTimeStamp(time())) cnfParse.set(cnfSec, "timestamp", formatTimeStamp(time()))
cnfParse.set(cnfSec,"theme", str(self.guiTheme)) cnfParse.set(cnfSec, "theme", str(self.guiTheme))
cnfParse.set(cnfSec,"syntax", str(self.guiSyntax)) cnfParse.set(cnfSec, "syntax", str(self.guiSyntax))
cnfParse.set(cnfSec,"icons", str(self.guiIcons)) cnfParse.set(cnfSec, "icons", str(self.guiIcons))
cnfParse.set(cnfSec,"guidark", str(self.guiDark)) cnfParse.set(cnfSec, "guidark", str(self.guiDark))
cnfParse.set(cnfSec,"guifont", str(self.guiFont)) cnfParse.set(cnfSec, "guifont", str(self.guiFont))
cnfParse.set(cnfSec,"guifontsize", str(self.guiFontSize)) cnfParse.set(cnfSec, "guifontsize", str(self.guiFontSize))
## Sizes ## Sizes
cnfSec = "Sizes" cnfSec = "Sizes"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"geometry", self._packList(self.winGeometry)) cnfParse.set(cnfSec, "geometry", self._packList(self.winGeometry))
cnfParse.set(cnfSec,"treecols", self._packList(self.treeColWidth)) cnfParse.set(cnfSec, "treecols", self._packList(self.treeColWidth))
cnfParse.set(cnfSec,"projcols", self._packList(self.projColWidth)) cnfParse.set(cnfSec, "projcols", self._packList(self.projColWidth))
cnfParse.set(cnfSec,"mainpane", self._packList(self.mainPanePos)) cnfParse.set(cnfSec, "mainpane", self._packList(self.mainPanePos))
cnfParse.set(cnfSec,"docpane", self._packList(self.docPanePos)) cnfParse.set(cnfSec, "docpane", self._packList(self.docPanePos))
cnfParse.set(cnfSec,"viewpane", self._packList(self.viewPanePos)) cnfParse.set(cnfSec, "viewpane", self._packList(self.viewPanePos))
cnfParse.set(cnfSec,"outlinepane", self._packList(self.outlnPanePos)) cnfParse.set(cnfSec, "outlinepane", self._packList(self.outlnPanePos))
cnfParse.set(cnfSec,"fullscreen", str(self.isFullScreen)) cnfParse.set(cnfSec, "fullscreen", str(self.isFullScreen))
## Project ## Project
cnfSec = "Project" cnfSec = "Project"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"autosaveproject", str(self.autoSaveProj)) cnfParse.set(cnfSec, "autosaveproject", str(self.autoSaveProj))
cnfParse.set(cnfSec,"autosavedoc", str(self.autoSaveDoc)) cnfParse.set(cnfSec, "autosavedoc", str(self.autoSaveDoc))
## Editor ## Editor
cnfSec = "Editor" cnfSec = "Editor"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"textfont", str(self.textFont)) cnfParse.set(cnfSec, "textfont", str(self.textFont))
cnfParse.set(cnfSec,"textsize", str(self.textSize)) cnfParse.set(cnfSec, "textsize", str(self.textSize))
cnfParse.set(cnfSec,"fixedwidth", str(self.textFixedW)) cnfParse.set(cnfSec, "fixedwidth", str(self.textFixedW))
cnfParse.set(cnfSec,"width", str(self.textWidth)) cnfParse.set(cnfSec, "width", str(self.textWidth))
cnfParse.set(cnfSec,"margin", str(self.textMargin)) cnfParse.set(cnfSec, "margin", str(self.textMargin))
cnfParse.set(cnfSec,"tabwidth", str(self.tabWidth)) cnfParse.set(cnfSec, "tabwidth", str(self.tabWidth))
cnfParse.set(cnfSec,"focuswidth", str(self.focusWidth)) cnfParse.set(cnfSec, "focuswidth", str(self.focusWidth))
cnfParse.set(cnfSec,"hidefocusfooter", str(self.hideFocusFooter)) cnfParse.set(cnfSec, "hidefocusfooter", str(self.hideFocusFooter))
cnfParse.set(cnfSec,"justify", str(self.doJustify)) cnfParse.set(cnfSec, "justify", str(self.doJustify))
cnfParse.set(cnfSec,"autoselect", str(self.autoSelect)) cnfParse.set(cnfSec, "autoselect", str(self.autoSelect))
cnfParse.set(cnfSec,"autoreplace", str(self.doReplace)) cnfParse.set(cnfSec, "autoreplace", str(self.doReplace))
cnfParse.set(cnfSec,"repsquotes", str(self.doReplaceSQuote)) cnfParse.set(cnfSec, "repsquotes", str(self.doReplaceSQuote))
cnfParse.set(cnfSec,"repdquotes", str(self.doReplaceDQuote)) cnfParse.set(cnfSec, "repdquotes", str(self.doReplaceDQuote))
cnfParse.set(cnfSec,"repdash", str(self.doReplaceDash)) cnfParse.set(cnfSec, "repdash", str(self.doReplaceDash))
cnfParse.set(cnfSec,"repdots", str(self.doReplaceDots)) cnfParse.set(cnfSec, "repdots", str(self.doReplaceDots))
cnfParse.set(cnfSec,"fmtsinglequote", self._packList(self.fmtSingleQuotes)) cnfParse.set(cnfSec, "fmtsinglequote", self._packList(self.fmtSingleQuotes))
cnfParse.set(cnfSec,"fmtdoublequote", self._packList(self.fmtDoubleQuotes)) cnfParse.set(cnfSec, "fmtdoublequote", self._packList(self.fmtDoubleQuotes))
cnfParse.set(cnfSec,"spelltool", str(self.spellTool)) cnfParse.set(cnfSec, "spelltool", str(self.spellTool))
cnfParse.set(cnfSec,"spellcheck", str(self.spellLanguage)) cnfParse.set(cnfSec, "spellcheck", str(self.spellLanguage))
cnfParse.set(cnfSec,"showtabsnspaces", str(self.showTabsNSpaces)) cnfParse.set(cnfSec, "showtabsnspaces", str(self.showTabsNSpaces))
cnfParse.set(cnfSec,"showlineendings", str(self.showLineEndings)) cnfParse.set(cnfSec, "showlineendings", str(self.showLineEndings))
cnfParse.set(cnfSec,"bigdoclimit", str(self.bigDocLimit)) cnfParse.set(cnfSec, "bigdoclimit", str(self.bigDocLimit))
cnfParse.set(cnfSec,"showfullpath", str(self.showFullPath)) cnfParse.set(cnfSec, "showfullpath", str(self.showFullPath))
cnfParse.set(cnfSec,"highlightquotes", str(self.highlightQuotes)) cnfParse.set(cnfSec, "highlightquotes", str(self.highlightQuotes))
cnfParse.set(cnfSec,"highlightemph", str(self.highlightEmph)) cnfParse.set(cnfSec, "highlightemph", str(self.highlightEmph))
## Backup ## Backup
cnfSec = "Backup" cnfSec = "Backup"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"backuppath", str(self.backupPath)) cnfParse.set(cnfSec, "backuppath", str(self.backupPath))
cnfParse.set(cnfSec,"backuponclose", str(self.backupOnClose)) cnfParse.set(cnfSec, "backuponclose", str(self.backupOnClose))
cnfParse.set(cnfSec,"askbeforebackup",str(self.askBeforeBackup)) cnfParse.set(cnfSec, "askbeforebackup", str(self.askBeforeBackup))
## State ## State
cnfSec = "State" cnfSec = "State"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"showrefpanel", str(self.showRefPanel)) cnfParse.set(cnfSec, "showrefpanel", str(self.showRefPanel))
cnfParse.set(cnfSec,"viewcomments", str(self.viewComments)) cnfParse.set(cnfSec, "viewcomments", str(self.viewComments))
cnfParse.set(cnfSec,"viewsynopsis", str(self.viewSynopsis)) cnfParse.set(cnfSec, "viewsynopsis", str(self.viewSynopsis))
cnfParse.set(cnfSec,"searchcase", str(self.searchCase)) cnfParse.set(cnfSec, "searchcase", str(self.searchCase))
cnfParse.set(cnfSec,"searchword", str(self.searchWord)) cnfParse.set(cnfSec, "searchword", str(self.searchWord))
cnfParse.set(cnfSec,"searchregex", str(self.searchRegEx)) cnfParse.set(cnfSec, "searchregex", str(self.searchRegEx))
cnfParse.set(cnfSec,"searchloop", str(self.searchLoop)) cnfParse.set(cnfSec, "searchloop", str(self.searchLoop))
cnfParse.set(cnfSec,"searchnextfile", str(self.searchNextFile)) cnfParse.set(cnfSec, "searchnextfile", str(self.searchNextFile))
cnfParse.set(cnfSec,"searchmatchcap", str(self.searchMatchCap)) cnfParse.set(cnfSec, "searchmatchcap", str(self.searchMatchCap))
## Path ## Path
cnfSec = "Path" cnfSec = "Path"
cnfParse.add_section(cnfSec) cnfParse.add_section(cnfSec)
cnfParse.set(cnfSec,"lastpath", str(self.lastPath)) cnfParse.set(cnfSec, "lastpath", str(self.lastPath))
# Write config file # Write config file
cnfPath = path.join(self.confPath, self.confFile) cnfPath = path.join(self.confPath, self.confFile)
+1 -1
View File
@@ -192,7 +192,7 @@ class NWDoc():
unlink(chkFile) unlink(chkFile)
logger.debug("Deleted: %s" % chkFile) logger.debug("Deleted: %s" % chkFile)
except Exception as e: except Exception as e:
self.makeAlert(["Could not delete document file.",str(e)], nwAlert.ERROR) self.makeAlert(["Could not delete document file.", str(e)], nwAlert.ERROR)
return False return False
return True return True
+2 -2
View File
@@ -135,7 +135,7 @@ class NWIndex():
if path.isfile(indexFile): if path.isfile(indexFile):
logger.debug("Loading index file") logger.debug("Loading index file")
try: try:
with open(indexFile,mode="r",encoding="utf8") as inFile: with open(indexFile, mode="r", encoding="utf8") as inFile:
theJson = inFile.read() theJson = inFile.read()
theData = json.loads(theJson) theData = json.loads(theJson)
except Exception as e: except Exception as e:
@@ -520,7 +520,7 @@ class NWIndex():
return isGood return isGood
# If we're still here, we better check that the references exist # If we're still here, we better check that the references exist
for n in range(1,nBits): for n in range(1, nBits):
if theBits[n] in self.tagIndex: if theBits[n] in self.tagIndex:
isGood[n] = self.TAG_CLASS[theBits[0]].name == self.tagIndex[theBits[n]][2] isGood[n] = self.TAG_CLASS[theBits[0]].name == self.tagIndex[theBits[n]][2]
+12 -12
View File
@@ -68,24 +68,24 @@ class NWItem():
def packXML(self, xParent): def packXML(self, xParent):
"""Packs all the data in the class instance into an XML object. """Packs all the data in the class instance into an XML object.
""" """
xPack = etree.SubElement(xParent,"item",attrib={ xPack = etree.SubElement(xParent, "item", attrib={
"handle" : str(self.itemHandle), "handle" : str(self.itemHandle),
"order" : str(self.itemOrder), "order" : str(self.itemOrder),
"parent" : str(self.parHandle), "parent" : str(self.parHandle),
}) })
xSub = self._subPack(xPack,"name", text=str(self.itemName)) xSub = self._subPack(xPack, "name", text=str(self.itemName))
xSub = self._subPack(xPack,"type", text=str(self.itemType.name)) xSub = self._subPack(xPack, "type", text=str(self.itemType.name))
xSub = self._subPack(xPack,"class", text=str(self.itemClass.name)) xSub = self._subPack(xPack, "class", text=str(self.itemClass.name))
xSub = self._subPack(xPack,"status", text=str(self.itemStatus)) xSub = self._subPack(xPack, "status", text=str(self.itemStatus))
if self.itemType == nwItemType.FILE: if self.itemType == nwItemType.FILE:
xSub = self._subPack(xPack,"exported", text=str(self.isExported)) xSub = self._subPack(xPack, "exported", text=str(self.isExported))
xSub = self._subPack(xPack,"layout", text=str(self.itemLayout.name)) xSub = self._subPack(xPack, "layout", text=str(self.itemLayout.name))
xSub = self._subPack(xPack,"charCount", text=str(self.charCount), none=False) xSub = self._subPack(xPack, "charCount", text=str(self.charCount), none=False)
xSub = self._subPack(xPack,"wordCount", text=str(self.wordCount), none=False) xSub = self._subPack(xPack, "wordCount", text=str(self.wordCount), none=False)
xSub = self._subPack(xPack,"paraCount", text=str(self.paraCount), none=False) xSub = self._subPack(xPack, "paraCount", text=str(self.paraCount), none=False)
xSub = self._subPack(xPack,"cursorPos", text=str(self.cursorPos), none=False) xSub = self._subPack(xPack, "cursorPos", text=str(self.cursorPos), none=False)
else: else:
xSub = self._subPack(xPack,"expanded", text=str(self.isExpanded)) xSub = self._subPack(xPack, "expanded", text=str(self.isExpanded))
return return
def unpackXML(self, xItem): def unpackXML(self, xItem):
+13 -13
View File
@@ -206,15 +206,15 @@ class NWProject():
self.spellCheck = False self.spellCheck = False
self.autoOutline = True self.autoOutline = True
self.statusItems = NWStatus() self.statusItems = NWStatus()
self.statusItems.addEntry("New", (100, 100, 100)) self.statusItems.addEntry("New", (100, 100, 100))
self.statusItems.addEntry("Note", (200, 50, 0)) self.statusItems.addEntry("Note", (200, 50, 0))
self.statusItems.addEntry("Draft", (200, 150, 0)) self.statusItems.addEntry("Draft", (200, 150, 0))
self.statusItems.addEntry("Finished",( 50, 200, 0)) self.statusItems.addEntry("Finished", ( 50, 200, 0))
self.importItems = NWStatus() self.importItems = NWStatus()
self.importItems.addEntry("New", (100, 100, 100)) self.importItems.addEntry("New", (100, 100, 100))
self.importItems.addEntry("Minor", (200, 50, 0)) self.importItems.addEntry("Minor", (200, 50, 0))
self.importItems.addEntry("Major", (200, 150, 0)) self.importItems.addEntry("Major", (200, 150, 0))
self.importItems.addEntry("Main", ( 50, 200, 0)) self.importItems.addEntry("Main", ( 50, 200, 0))
self.lastEdited = None self.lastEdited = None
self.lastViewed = None self.lastViewed = None
self.lastWCount = 0 self.lastWCount = 0
@@ -421,7 +421,7 @@ class NWProject():
try: try:
nwXML = etree.parse(fileName) nwXML = etree.parse(fileName)
except Exception as e: except Exception as e:
self.makeAlert(["Failed to parse project xml.",str(e)], nwAlert.ERROR) self.makeAlert(["Failed to parse project xml.", str(e)], nwAlert.ERROR)
# Trying to open backup file instead # Trying to open backup file instead
backFile = fileName[:-3]+"bak" backFile = fileName[:-3]+"bak"
@@ -430,7 +430,7 @@ class NWProject():
try: try:
nwXML = etree.parse(backFile) nwXML = etree.parse(backFile)
except Exception as e: except Exception as e:
self.makeAlert(["Failed to parse project xml.",str(e)], nwAlert.ERROR) self.makeAlert(["Failed to parse project xml.", str(e)], nwAlert.ERROR)
self.clearProject() self.clearProject()
return False return False
else: else:
@@ -794,7 +794,7 @@ class NWProject():
logger.debug("Created folder %s" % baseDir) logger.debug("Created folder %s" % baseDir)
except Exception as e: except Exception as e:
self.theParent.makeAlert( self.theParent.makeAlert(
["Could not create backup folder.",str(e)], ["Could not create backup folder.", str(e)],
nwAlert.ERROR nwAlert.ERROR
) )
return False return False
@@ -823,7 +823,7 @@ class NWProject():
logger.info("Backup written to: %s" % archName) logger.info("Backup written to: %s" % archName)
except Exception as e: except Exception as e:
self.theParent.makeAlert( self.theParent.makeAlert(
["Could not write backup archive.",str(e)], ["Could not write backup archive.", str(e)],
nwAlert.ERROR nwAlert.ERROR
) )
return False return False
@@ -1231,7 +1231,7 @@ class NWProject():
mkdir(thePath) mkdir(thePath)
logger.debug("Created folder %s" % thePath) logger.debug("Created folder %s" % thePath)
except Exception as e: except Exception as e:
self.makeAlert(["Could not create folder.",str(e)], nwAlert.ERROR) self.makeAlert(["Could not create folder.", str(e)], nwAlert.ERROR)
return False return False
return True return True
+5 -5
View File
@@ -75,7 +75,7 @@ class NWSpellCheck():
newWord = newWord.strip() newWord = newWord.strip()
self.PROJW.append(newWord) self.PROJW.append(newWord)
try: try:
with open(self.projectDict,mode="a+",encoding="utf-8") as outFile: with open(self.projectDict, mode="a+", encoding="utf-8") as outFile:
outFile.write("%s\n" % newWord) outFile.write("%s\n" % newWord)
except Exception as e: except Exception as e:
logger.error("Failed to add word to project word list %s" % str(self.projectDict)) logger.error("Failed to add word to project word list %s" % str(self.projectDict))
@@ -231,9 +231,9 @@ class NWSpellSimple(NWSpellCheck):
"""Load a dictionary as a list from the app assets folder. """Load a dictionary as a list from the app assets folder.
""" """
self.WORDS = [] self.WORDS = []
dictFile = path.join(self.mainConf.dictPath,theLang+".dict") dictFile = path.join(self.mainConf.dictPath, theLang+".dict")
try: try:
with open(dictFile,mode="r",encoding="utf-8") as wordsFile: with open(dictFile, mode="r", encoding="utf-8") as wordsFile:
for theLine in wordsFile: for theLine in wordsFile:
if len(theLine) == 0 or theLine.startswith("#"): if len(theLine) == 0 or theLine.startswith("#"):
continue continue
@@ -258,7 +258,7 @@ class NWSpellSimple(NWSpellCheck):
this function as fast as possible as it is called for every this function as fast as possible as it is called for every
word by the syntax highlighter. word by the syntax highlighter.
""" """
theWord = theWord.replace(self.mainConf.fmtApostrophe,"'").lower() theWord = theWord.replace(self.mainConf.fmtApostrophe, "'").lower()
return theWord in self.WORDS return theWord in self.WORDS
def suggestWords(self, theWord): def suggestWords(self, theWord):
@@ -282,7 +282,7 @@ class NWSpellSimple(NWSpellCheck):
continue continue
if firstUp: if firstUp:
aWord = aWord[0].upper() + aWord[1:] aWord = aWord[0].upper() + aWord[1:]
aWord = aWord.replace("'",self.mainConf.fmtApostrophe) aWord = aWord.replace("'", self.mainConf.fmtApostrophe)
theOptions.append(aWord) theOptions.append(aWord)
return theOptions return theOptions
+5 -5
View File
@@ -121,7 +121,7 @@ class NWStatus():
main project file. main project file.
""" """
for n in range(self.theLength): for n in range(self.theLength):
xSub = etree.SubElement(xParent,"entry",attrib={ xSub = etree.SubElement(xParent, "entry", attrib={
"blue" : str(self.theColours[n][2]), "blue" : str(self.theColours[n][2]),
"green" : str(self.theColours[n][1]), "green" : str(self.theColours[n][1]),
"red" : str(self.theColours[n][0]), "red" : str(self.theColours[n][0]),
@@ -138,18 +138,18 @@ class NWStatus():
for xChild in xParent: for xChild in xParent:
theLabels.append(xChild.text) theLabels.append(xChild.text)
if "red" in xChild.attrib: if "red" in xChild.attrib:
cR = checkInt(xChild.attrib["red"],0,False) cR = checkInt(xChild.attrib["red"], 0, False)
else: else:
cR = 0 cR = 0
if "green" in xChild.attrib: if "green" in xChild.attrib:
cG = checkInt(xChild.attrib["green"],0,False) cG = checkInt(xChild.attrib["green"], 0, False)
else: else:
cG = 0 cG = 0
if "blue" in xChild.attrib: if "blue" in xChild.attrib:
cB = checkInt(xChild.attrib["blue"],0,False) cB = checkInt(xChild.attrib["blue"], 0, False)
else: else:
cB = 0 cB = 0
theColours.append((cR,cG,cB)) theColours.append((cR, cG, cB))
if len(theLabels) > 0: if len(theLabels) > 0:
self.theLabels = [] self.theLabels = []
+3 -3
View File
@@ -418,11 +418,11 @@ class Tokenizer():
rxThis = theRX.globalMatch(aLine, 0) rxThis = theRX.globalMatch(aLine, 0)
while rxThis.hasNext(): while rxThis.hasNext():
rxMatch = rxThis.next() rxMatch = rxThis.next()
for n in range(1,len(theKeys)): for n in range(1, len(theKeys)):
if theKeys[n] is not None: if theKeys[n] is not None:
xPos = rxMatch.capturedStart(n) xPos = rxMatch.capturedStart(n)
xLen = rxMatch.capturedLength(n) xLen = rxMatch.capturedLength(n)
fmtPos.append([xPos,xLen,theKeys[n]]) fmtPos.append([xPos, xLen, theKeys[n]])
# Save the line as is, but append the array of formatting locations # Save the line as is, but append the array of formatting locations
# sorted by position # sorted by position
@@ -686,7 +686,7 @@ class Tokenizer():
theTitle = theTitle.replace(r"%sc%", str(self.numChScene)) theTitle = theTitle.replace(r"%sc%", str(self.numChScene))
theTitle = theTitle.replace(r"%sca%", str(self.numAbsScene)) theTitle = theTitle.replace(r"%sca%", str(self.numAbsScene))
if r"%chw%" in theTitle: if r"%chw%" in theTitle:
theTitle = theTitle.replace(r"%chw%", numberToWord(self.numChapter,"en")) theTitle = theTitle.replace(r"%chw%", numberToWord(self.numChapter, "en"))
if r"%chi%" in theTitle: if r"%chi%" in theTitle:
theTitle = theTitle.replace(r"%chi%", numberToRoman(self.numChapter, True)) theTitle = theTitle.replace(r"%chi%", numberToRoman(self.numChapter, True))
if r"%chI%" in theTitle: if r"%chI%" in theTitle:
+1 -1
View File
@@ -73,7 +73,7 @@ def countWords(theText):
charCount -= 2 charCount -= 2
countPara = False countPara = False
theBuff = aLine.replace(""," ").replace(""," ") theBuff = aLine.replace("", " ").replace("", " ")
wordCount += len(theBuff.split()) wordCount += len(theBuff.split())
charCount += theLen charCount += theLen
if countPara and prevEmpty: if countPara and prevEmpty:
+2 -2
View File
@@ -114,7 +114,7 @@ class NWTree():
"""Pack the content of the tree into an XML object. """Pack the content of the tree into an XML object.
""" """
xContent = etree.SubElement(xParent, "content", attrib={ xContent = etree.SubElement(xParent, "content", attrib={
"count":str(self._theLength)} "count": str(self._theLength)}
) )
for tHandle in self._treeOrder: for tHandle in self._treeOrder:
tItem = self.__getitem__(tHandle) tItem = self.__getitem__(tHandle)
@@ -154,7 +154,7 @@ class NWTree():
outFile.write(" Table of Contents\n") outFile.write(" Table of Contents\n")
outFile.write("===================\n") outFile.write("===================\n")
outFile.write("\n") outFile.write("\n")
outFile.write(" %-25s %-9s %s\n" %("File Name","Class","Document Label")) outFile.write(" %-25s %-9s %s\n" %("File Name", "Class", "Document Label"))
outFile.write("-"*80+"\n") outFile.write("-"*80+"\n")
for tHandle in sorted(self._treeOrder): for tHandle in sorted(self._treeOrder):
tItem = self.__getitem__(tHandle) tItem = self.__getitem__(tHandle)
+2 -2
View File
@@ -1475,12 +1475,12 @@ class GuiDocEditSearch(QFrame):
self.showReplace.setStyleSheet(r"QToolButton {border: none; background: transparent;}") self.showReplace.setStyleSheet(r"QToolButton {border: none; background: transparent;}")
self.showReplace.toggled.connect(self._doToggleReplace) self.showReplace.toggled.connect(self._doToggleReplace)
self.searchButton = QPushButton(self.theTheme.getIcon("search"),"") self.searchButton = QPushButton(self.theTheme.getIcon("search"), "")
self.searchButton.setFixedSize(QSize(bPx, bPx)) self.searchButton.setFixedSize(QSize(bPx, bPx))
self.searchButton.setToolTip("Find in current document") self.searchButton.setToolTip("Find in current document")
self.searchButton.clicked.connect(self._doSearch) self.searchButton.clicked.connect(self._doSearch)
self.replaceButton = QPushButton(self.theTheme.getIcon("search-replace"),"") self.replaceButton = QPushButton(self.theTheme.getIcon("search-replace"), "")
self.replaceButton.setFixedSize(QSize(bPx, bPx)) self.replaceButton.setFixedSize(QSize(bPx, bPx))
self.replaceButton.setToolTip("Find and replace in current document") self.replaceButton.setToolTip("Find and replace in current document")
self.replaceButton.clicked.connect(self._doReplace) self.replaceButton.clicked.connect(self._doReplace)
+13 -13
View File
@@ -55,18 +55,18 @@ class GuiDocHighlighter(QSyntaxHighlighter):
self.hRules = [] self.hRules = []
self.hStyles = {} self.hStyles = {}
self.colHead = QColor(0,0,0) self.colHead = QColor(0, 0, 0)
self.colHeadH = QColor(0,0,0) self.colHeadH = QColor(0, 0, 0)
self.colEmph = QColor(0,0,0) self.colEmph = QColor(0, 0, 0)
self.colDialN = QColor(0,0,0) self.colDialN = QColor(0, 0, 0)
self.colDialD = QColor(0,0,0) self.colDialD = QColor(0, 0, 0)
self.colDialS = QColor(0,0,0) self.colDialS = QColor(0, 0, 0)
self.colComm = QColor(0,0,0) self.colComm = QColor(0, 0, 0)
self.colKey = QColor(0,0,0) self.colKey = QColor(0, 0, 0)
self.colVal = QColor(0,0,0) self.colVal = QColor(0, 0, 0)
self.colSpell = QColor(0,0,0) self.colSpell = QColor(0, 0, 0)
self.colTagErr = QColor(0,0,0) self.colTagErr = QColor(0, 0, 0)
self.colRepTag = QColor(0,0,0) self.colRepTag = QColor(0, 0, 0)
self.initHighlighter() self.initHighlighter()
@@ -143,7 +143,7 @@ class GuiDocHighlighter(QSyntaxHighlighter):
# Quoted Strings # Quoted Strings
if self.mainConf.highlightQuotes: if self.mainConf.highlightQuotes:
self.hRules.append(( self.hRules.append((
"{:s}(.+?){:s}".format('"','"'), { "{:s}(.+?){:s}".format('"', '"'), {
0 : self.hStyles["dialogue1"], 0 : self.hStyles["dialogue1"],
} }
)) ))
+1 -1
View File
@@ -238,7 +238,7 @@ class GuiItemDetails(QWidget):
else: else:
self.labelFlag.setPixmap(self.expCross) self.labelFlag.setPixmap(self.expCross)
else: else:
self.labelFlag.setPixmap(QPixmap(1,1)) self.labelFlag.setPixmap(QPixmap(1, 1))
self.statusFlag.setPixmap(flagIcon.pixmap(self.sPx, self.sPx)) self.statusFlag.setPixmap(flagIcon.pixmap(self.sPx, self.sPx))
self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass]) self.classFlag.setText(nwLabels.CLASS_FLAG[nwItem.itemClass])
if nwItem.itemLayout == nwItemLayout.NO_LAYOUT: if nwItem.itemLayout == nwItemLayout.NO_LAYOUT:
+1 -1
View File
@@ -96,7 +96,7 @@ class GuiItemEditor(QDialog):
for itemLayout in nwItemLayout: for itemLayout in nwItemLayout:
if itemLayout in self.validLayouts: if itemLayout in self.validLayouts:
self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout],itemLayout) self.editLayout.addItem(nwLabels.LAYOUT_NAME[itemLayout], itemLayout)
# Export Switch # Export Switch
self.textExport = QLabel("Include when building project") self.textExport = QLabel("Include when building project")
+6 -6
View File
@@ -607,9 +607,9 @@ class GuiMainMenu(QMenuBar):
self.aFindNext = QAction("Find Next", self) self.aFindNext = QAction("Find Next", self)
self.aFindNext.setStatusTip("Find next occurrence text in document") self.aFindNext.setStatusTip("Find next occurrence text in document")
if self.mainConf.osDarwin: if self.mainConf.osDarwin:
self.aFindNext.setShortcuts(["Ctrl+G","F3"]) self.aFindNext.setShortcuts(["Ctrl+G", "F3"])
else: else:
self.aFindNext.setShortcuts(["F3","Ctrl+G"]) self.aFindNext.setShortcuts(["F3", "Ctrl+G"])
self.aFindNext.triggered.connect(lambda: self._docAction(nwDocAction.GO_NEXT)) self.aFindNext.triggered.connect(lambda: self._docAction(nwDocAction.GO_NEXT))
self.srcMenu.addAction(self.aFindNext) self.srcMenu.addAction(self.aFindNext)
@@ -617,9 +617,9 @@ class GuiMainMenu(QMenuBar):
self.aFindPrev = QAction("Find Previous", self) self.aFindPrev = QAction("Find Previous", self)
self.aFindPrev.setStatusTip("Find previous occurrence text in document") self.aFindPrev.setStatusTip("Find previous occurrence text in document")
if self.mainConf.osDarwin: if self.mainConf.osDarwin:
self.aFindPrev.setShortcuts(["Ctrl+Shift+G","Shift+F3"]) self.aFindPrev.setShortcuts(["Ctrl+Shift+G", "Shift+F3"])
else: else:
self.aFindPrev.setShortcuts(["Shift+F3","Ctrl+Shift+G"]) self.aFindPrev.setShortcuts(["Shift+F3", "Ctrl+Shift+G"])
self.aFindPrev.triggered.connect(lambda: self._docAction(nwDocAction.GO_PREV)) self.aFindPrev.triggered.connect(lambda: self._docAction(nwDocAction.GO_PREV))
self.srcMenu.addAction(self.aFindPrev) self.srcMenu.addAction(self.aFindPrev)
@@ -717,7 +717,7 @@ class GuiMainMenu(QMenuBar):
# Format > Remove Block Format # Format > Remove Block Format
self.aFmtNoFormat = QAction("Remove Block Format", self) self.aFmtNoFormat = QAction("Remove Block Format", self)
self.aFmtNoFormat.setStatusTip("Strips block format") self.aFmtNoFormat.setStatusTip("Strips block format")
self.aFmtNoFormat.setShortcuts(["Ctrl+0","Ctrl+Shift+/"]) self.aFmtNoFormat.setShortcuts(["Ctrl+0", "Ctrl+Shift+/"])
self.aFmtNoFormat.triggered.connect(lambda: self._docAction(nwDocAction.BLOCK_TXT)) self.aFmtNoFormat.triggered.connect(lambda: self._docAction(nwDocAction.BLOCK_TXT))
self.fmtMenu.addAction(self.aFmtNoFormat) self.fmtMenu.addAction(self.aFmtNoFormat)
@@ -870,7 +870,7 @@ class GuiMainMenu(QMenuBar):
if self.mainConf.hasHelp and self.mainConf.hasAssistant: if self.mainConf.hasHelp and self.mainConf.hasAssistant:
self.aHelpWeb.setShortcut("Shift+F1") self.aHelpWeb.setShortcut("Shift+F1")
else: else:
self.aHelpWeb.setShortcuts(["F1","Shift+F1"]) self.aHelpWeb.setShortcuts(["F1", "Shift+F1"])
self.helpMenu.addAction(self.aHelpWeb) self.helpMenu.addAction(self.aHelpWeb)
# Document > Go to Website # Document > Go to Website
+1 -1
View File
@@ -342,7 +342,7 @@ class GuiConfigEditGeneralTab(QWidget):
dlgOpt |= QFileDialog.ShowDirsOnly dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog dlgOpt |= QFileDialog.DontUseNativeDialog
newDir = QFileDialog.getExistingDirectory( newDir = QFileDialog.getExistingDirectory(
self,"Backup Directory",currDir,options=dlgOpt self, "Backup Directory", currDir, options=dlgOpt
) )
if newDir: if newDir:
self.backupPath = newDir self.backupPath = newDir
+9 -9
View File
@@ -69,11 +69,11 @@ class GuiProjectSettings(PagedDialog):
self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject, False) self.tabImport = GuiProjectEditStatus(self.theParent, self.theProject, False)
self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject) self.tabReplace = GuiProjectEditReplace(self.theParent, self.theProject)
self.addTab(self.tabMain, "Settings") self.addTab(self.tabMain, "Settings")
self.addTab(self.tabMeta, "Details") self.addTab(self.tabMeta, "Details")
self.addTab(self.tabStatus, "Status") self.addTab(self.tabStatus, "Status")
self.addTab(self.tabImport, "Importance") self.addTab(self.tabImport, "Importance")
self.addTab(self.tabReplace,"Auto-Replace") self.addTab(self.tabReplace, "Auto-Replace")
self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
self.buttonBox.accepted.connect(self._doSave) self.buttonBox.accepted.connect(self._doSave)
@@ -331,7 +331,7 @@ class GuiProjectEditStatus(QWidget):
self.saveButton = QPushButton("Save") self.saveButton = QPushButton("Save")
self.colPixmap = QPixmap(self.iPx, self.iPx) self.colPixmap = QPixmap(self.iPx, self.iPx)
self.colPixmap.fill(QColor(120, 120, 120)) self.colPixmap.fill(QColor(120, 120, 120))
self.colButton = QPushButton(QIcon(self.colPixmap),"Colour") self.colButton = QPushButton(QIcon(self.colPixmap), "Colour")
self.colButton.setIconSize(self.colPixmap.rect().size()) self.colButton.setIconSize(self.colPixmap.rect().size())
self.newButton.clicked.connect(self._newItem) self.newButton.clicked.connect(self._newItem)
@@ -513,7 +513,7 @@ class GuiProjectEditReplace(QWidget):
self.optState.getInt("GuiProjectSettings", "replaceColW", 100) self.optState.getInt("GuiProjectSettings", "replaceColW", 100)
) )
self.listBox = QTreeWidget() self.listBox = QTreeWidget()
self.listBox.setHeaderLabels(["Keyword","Replace With"]) self.listBox.setHeaderLabels(["Keyword", "Replace With"])
self.listBox.itemSelectionChanged.connect(self._selectedItem) self.listBox.itemSelectionChanged.connect(self._selectedItem)
self.listBox.setColumnWidth(0, wCol0) self.listBox.setColumnWidth(0, wCol0)
self.listBox.setIndentation(0) self.listBox.setIndentation(0)
@@ -601,8 +601,8 @@ class GuiProjectEditReplace(QWidget):
saveKey = self._stripNotAllowed(newKey) saveKey = self._stripNotAllowed(newKey)
if len(saveKey) > 0 and len(newVal) > 0: if len(saveKey) > 0 and len(newVal) > 0:
selItem.setText(0,"<%s>" % saveKey) selItem.setText(0, "<%s>" % saveKey)
selItem.setText(1,newVal) selItem.setText(1, newVal)
self.editKey.clear() self.editKey.clear()
self.editValue.clear() self.editValue.clear()
self.editKey.setEnabled(False) self.editKey.setEnabled(False)
+2 -2
View File
@@ -543,7 +543,7 @@ class GuiProjectTree(QTreeWidget):
self.theProject.setProjectWordCount(nWords) self.theProject.setProjectWordCount(nWords)
sWords = self.theProject.getSessionWordCount() sWords = self.theProject.getSessionWordCount()
self.theParent.statusBar.setStats(nWords,sWords) self.theParent.statusBar.setStats(nWords, sWords)
return return
@@ -841,7 +841,7 @@ class GuiProjectTree(QTreeWidget):
self.setTreeItemValues(tHandle) self.setTreeItemValues(tHandle)
self._setTreeChanged(True) self._setTreeChanged(True)
logger.debug("The parent of item %s has been changed to %s" % (tHandle,pHandle)) logger.debug("The parent of item %s has been changed to %s" % (tHandle, pHandle))
return True return True
+1 -1
View File
@@ -214,7 +214,7 @@ class ProjWizardFolderPage(QWizardPage):
dlgOpt |= QFileDialog.ShowDirsOnly dlgOpt |= QFileDialog.ShowDirsOnly
dlgOpt |= QFileDialog.DontUseNativeDialog dlgOpt |= QFileDialog.DontUseNativeDialog
projDir = QFileDialog.getExistingDirectory( projDir = QFileDialog.getExistingDirectory(
self,"Select Project Folder", lastPath, options=dlgOpt self, "Select Project Folder", lastPath, options=dlgOpt
) )
if projDir: if projDir:
projName = self.field("projName") projName = self.field("projName")
+1 -1
View File
@@ -212,7 +212,7 @@ class GuiMainStatus(QStatusBar):
tH = int(tM/60) tH = int(tM/60)
tM = tM - tH*60 tM = tM - tH*60
tS = tS - tM*60 - tH*3600 tS = tS - tM*60 - tH*3600
theTime = "%02d:%02d:%02d" % (tH,tM,tS) theTime = "%02d:%02d:%02d" % (tH, tM, tS)
self.timeText.setText(theTime) self.timeText.setText(theTime)
return return
+4 -4
View File
@@ -431,8 +431,8 @@ class GuiTheme:
def _loadColour(self, confParser, cnfSec, cnfName): def _loadColour(self, confParser, cnfSec, cnfName):
"""Load a colour value from a config string. """Load a colour value from a config string.
""" """
if confParser.has_option(cnfSec,cnfName): if confParser.has_option(cnfSec, cnfName):
inData = confParser.get(cnfSec,cnfName).split(",") inData = confParser.get(cnfSec, cnfName).split(",")
outData = [] outData = []
try: try:
outData.append(int(inData[0])) outData.append(int(inData[0]))
@@ -450,8 +450,8 @@ class GuiTheme:
"""Set a palette colour value from a config string. """Set a palette colour value from a config string.
""" """
readCol = [] readCol = []
if confParser.has_option(cnfSec,cnfName): if confParser.has_option(cnfSec, cnfName):
inData = confParser.get(cnfSec,cnfName).split(",") inData = confParser.get(cnfSec, cnfName).split(",")
try: try:
readCol.append(int(inData[0])) readCol.append(int(inData[0]))
readCol.append(int(inData[1])) readCol.append(int(inData[1]))
+2 -2
View File
@@ -450,7 +450,7 @@ class GuiWritingStats(QDialog):
except Exception as e: except Exception as e:
self.theParent.makeAlert( self.theParent.makeAlert(
["Failed to read session log file.",str(e)], nwAlert.ERROR ["Failed to read session log file.", str(e)], nwAlert.ERROR
) )
return False return False
@@ -577,6 +577,6 @@ class GuiWritingStats(QDialog):
tH = int(tM/60) tH = int(tM/60)
tM = tM - tH*60 tM = tM - tH*60
tS = tS - tM*60 - tH*3600 tS = tS - tM*60 - tH*3600
return "%02d:%02d:%02d" % (tH,tM,tS) return "%02d:%02d:%02d" % (tH, tM, tS)
# END Class GuiWritingStats # END Class GuiWritingStats
+2 -2
View File
@@ -286,7 +286,7 @@ class GuiMain(QMainWindow):
logger.error("No projData or projPath set") logger.error("No projData or projPath set")
return False return False
if path.isfile(path.join(projPath,self.theProject.projFile)) and not forceNew: if path.isfile(path.join(projPath, self.theProject.projFile)) and not forceNew:
msgBox = QMessageBox() msgBox = QMessageBox()
msgRes = msgBox.critical( msgRes = msgBox.critical(
self, "New Project", self, "New Project",
@@ -597,7 +597,7 @@ class GuiMain(QMainWindow):
self.mainConf.setLastPath(loadFile) self.mainConf.setLastPath(loadFile)
except Exception as e: except Exception as e:
self.makeAlert( self.makeAlert(
["Could not read file. The file must be an existing text file.",str(e)], ["Could not read file. The file must be an existing text file.", str(e)],
nwAlert.ERROR nwAlert.ERROR
) )
return False return False