Fixed pycodestyle E231 errors
This commit is contained in:
+1
-1
@@ -192,7 +192,7 @@ class NWDoc():
|
||||
unlink(chkFile)
|
||||
logger.debug("Deleted: %s" % chkFile)
|
||||
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 True
|
||||
|
||||
+2
-2
@@ -135,7 +135,7 @@ class NWIndex():
|
||||
if path.isfile(indexFile):
|
||||
logger.debug("Loading index file")
|
||||
try:
|
||||
with open(indexFile,mode="r",encoding="utf8") as inFile:
|
||||
with open(indexFile, mode="r", encoding="utf8") as inFile:
|
||||
theJson = inFile.read()
|
||||
theData = json.loads(theJson)
|
||||
except Exception as e:
|
||||
@@ -520,7 +520,7 @@ class NWIndex():
|
||||
return isGood
|
||||
|
||||
# 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:
|
||||
isGood[n] = self.TAG_CLASS[theBits[0]].name == self.tagIndex[theBits[n]][2]
|
||||
|
||||
|
||||
+12
-12
@@ -68,24 +68,24 @@ class NWItem():
|
||||
def packXML(self, xParent):
|
||||
"""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),
|
||||
"order" : str(self.itemOrder),
|
||||
"parent" : str(self.parHandle),
|
||||
})
|
||||
xSub = self._subPack(xPack,"name", text=str(self.itemName))
|
||||
xSub = self._subPack(xPack,"type", text=str(self.itemType.name))
|
||||
xSub = self._subPack(xPack,"class", text=str(self.itemClass.name))
|
||||
xSub = self._subPack(xPack,"status", text=str(self.itemStatus))
|
||||
xSub = self._subPack(xPack, "name", text=str(self.itemName))
|
||||
xSub = self._subPack(xPack, "type", text=str(self.itemType.name))
|
||||
xSub = self._subPack(xPack, "class", text=str(self.itemClass.name))
|
||||
xSub = self._subPack(xPack, "status", text=str(self.itemStatus))
|
||||
if self.itemType == nwItemType.FILE:
|
||||
xSub = self._subPack(xPack,"exported", text=str(self.isExported))
|
||||
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,"wordCount", text=str(self.wordCount), 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, "exported", text=str(self.isExported))
|
||||
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, "wordCount", text=str(self.wordCount), none=False)
|
||||
xSub = self._subPack(xPack, "paraCount", text=str(self.paraCount), none=False)
|
||||
xSub = self._subPack(xPack, "cursorPos", text=str(self.cursorPos), none=False)
|
||||
else:
|
||||
xSub = self._subPack(xPack,"expanded", text=str(self.isExpanded))
|
||||
xSub = self._subPack(xPack, "expanded", text=str(self.isExpanded))
|
||||
return
|
||||
|
||||
def unpackXML(self, xItem):
|
||||
|
||||
+13
-13
@@ -206,15 +206,15 @@ class NWProject():
|
||||
self.spellCheck = False
|
||||
self.autoOutline = True
|
||||
self.statusItems = NWStatus()
|
||||
self.statusItems.addEntry("New", (100, 100, 100))
|
||||
self.statusItems.addEntry("Note", (200, 50, 0))
|
||||
self.statusItems.addEntry("Draft", (200, 150, 0))
|
||||
self.statusItems.addEntry("Finished",( 50, 200, 0))
|
||||
self.statusItems.addEntry("New", (100, 100, 100))
|
||||
self.statusItems.addEntry("Note", (200, 50, 0))
|
||||
self.statusItems.addEntry("Draft", (200, 150, 0))
|
||||
self.statusItems.addEntry("Finished", ( 50, 200, 0))
|
||||
self.importItems = NWStatus()
|
||||
self.importItems.addEntry("New", (100, 100, 100))
|
||||
self.importItems.addEntry("Minor", (200, 50, 0))
|
||||
self.importItems.addEntry("Major", (200, 150, 0))
|
||||
self.importItems.addEntry("Main", ( 50, 200, 0))
|
||||
self.importItems.addEntry("New", (100, 100, 100))
|
||||
self.importItems.addEntry("Minor", (200, 50, 0))
|
||||
self.importItems.addEntry("Major", (200, 150, 0))
|
||||
self.importItems.addEntry("Main", ( 50, 200, 0))
|
||||
self.lastEdited = None
|
||||
self.lastViewed = None
|
||||
self.lastWCount = 0
|
||||
@@ -421,7 +421,7 @@ class NWProject():
|
||||
try:
|
||||
nwXML = etree.parse(fileName)
|
||||
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
|
||||
backFile = fileName[:-3]+"bak"
|
||||
@@ -430,7 +430,7 @@ class NWProject():
|
||||
try:
|
||||
nwXML = etree.parse(backFile)
|
||||
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()
|
||||
return False
|
||||
else:
|
||||
@@ -794,7 +794,7 @@ class NWProject():
|
||||
logger.debug("Created folder %s" % baseDir)
|
||||
except Exception as e:
|
||||
self.theParent.makeAlert(
|
||||
["Could not create backup folder.",str(e)],
|
||||
["Could not create backup folder.", str(e)],
|
||||
nwAlert.ERROR
|
||||
)
|
||||
return False
|
||||
@@ -823,7 +823,7 @@ class NWProject():
|
||||
logger.info("Backup written to: %s" % archName)
|
||||
except Exception as e:
|
||||
self.theParent.makeAlert(
|
||||
["Could not write backup archive.",str(e)],
|
||||
["Could not write backup archive.", str(e)],
|
||||
nwAlert.ERROR
|
||||
)
|
||||
return False
|
||||
@@ -1231,7 +1231,7 @@ class NWProject():
|
||||
mkdir(thePath)
|
||||
logger.debug("Created folder %s" % thePath)
|
||||
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 True
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class NWSpellCheck():
|
||||
newWord = newWord.strip()
|
||||
self.PROJW.append(newWord)
|
||||
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)
|
||||
except Exception as e:
|
||||
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.
|
||||
"""
|
||||
self.WORDS = []
|
||||
dictFile = path.join(self.mainConf.dictPath,theLang+".dict")
|
||||
dictFile = path.join(self.mainConf.dictPath, theLang+".dict")
|
||||
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:
|
||||
if len(theLine) == 0 or theLine.startswith("#"):
|
||||
continue
|
||||
@@ -258,7 +258,7 @@ class NWSpellSimple(NWSpellCheck):
|
||||
this function as fast as possible as it is called for every
|
||||
word by the syntax highlighter.
|
||||
"""
|
||||
theWord = theWord.replace(self.mainConf.fmtApostrophe,"'").lower()
|
||||
theWord = theWord.replace(self.mainConf.fmtApostrophe, "'").lower()
|
||||
return theWord in self.WORDS
|
||||
|
||||
def suggestWords(self, theWord):
|
||||
@@ -282,7 +282,7 @@ class NWSpellSimple(NWSpellCheck):
|
||||
continue
|
||||
if firstUp:
|
||||
aWord = aWord[0].upper() + aWord[1:]
|
||||
aWord = aWord.replace("'",self.mainConf.fmtApostrophe)
|
||||
aWord = aWord.replace("'", self.mainConf.fmtApostrophe)
|
||||
theOptions.append(aWord)
|
||||
|
||||
return theOptions
|
||||
|
||||
+5
-5
@@ -121,7 +121,7 @@ class NWStatus():
|
||||
main project file.
|
||||
"""
|
||||
for n in range(self.theLength):
|
||||
xSub = etree.SubElement(xParent,"entry",attrib={
|
||||
xSub = etree.SubElement(xParent, "entry", attrib={
|
||||
"blue" : str(self.theColours[n][2]),
|
||||
"green" : str(self.theColours[n][1]),
|
||||
"red" : str(self.theColours[n][0]),
|
||||
@@ -138,18 +138,18 @@ class NWStatus():
|
||||
for xChild in xParent:
|
||||
theLabels.append(xChild.text)
|
||||
if "red" in xChild.attrib:
|
||||
cR = checkInt(xChild.attrib["red"],0,False)
|
||||
cR = checkInt(xChild.attrib["red"], 0, False)
|
||||
else:
|
||||
cR = 0
|
||||
if "green" in xChild.attrib:
|
||||
cG = checkInt(xChild.attrib["green"],0,False)
|
||||
cG = checkInt(xChild.attrib["green"], 0, False)
|
||||
else:
|
||||
cG = 0
|
||||
if "blue" in xChild.attrib:
|
||||
cB = checkInt(xChild.attrib["blue"],0,False)
|
||||
cB = checkInt(xChild.attrib["blue"], 0, False)
|
||||
else:
|
||||
cB = 0
|
||||
theColours.append((cR,cG,cB))
|
||||
theColours.append((cR, cG, cB))
|
||||
|
||||
if len(theLabels) > 0:
|
||||
self.theLabels = []
|
||||
|
||||
@@ -418,11 +418,11 @@ class Tokenizer():
|
||||
rxThis = theRX.globalMatch(aLine, 0)
|
||||
while rxThis.hasNext():
|
||||
rxMatch = rxThis.next()
|
||||
for n in range(1,len(theKeys)):
|
||||
for n in range(1, len(theKeys)):
|
||||
if theKeys[n] is not None:
|
||||
xPos = rxMatch.capturedStart(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
|
||||
# sorted by position
|
||||
@@ -686,7 +686,7 @@ class Tokenizer():
|
||||
theTitle = theTitle.replace(r"%sc%", str(self.numChScene))
|
||||
theTitle = theTitle.replace(r"%sca%", str(self.numAbsScene))
|
||||
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:
|
||||
theTitle = theTitle.replace(r"%chi%", numberToRoman(self.numChapter, True))
|
||||
if r"%chI%" in theTitle:
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ def countWords(theText):
|
||||
charCount -= 2
|
||||
countPara = False
|
||||
|
||||
theBuff = aLine.replace("–"," ").replace("—"," ")
|
||||
theBuff = aLine.replace("–", " ").replace("—", " ")
|
||||
wordCount += len(theBuff.split())
|
||||
charCount += theLen
|
||||
if countPara and prevEmpty:
|
||||
|
||||
+2
-2
@@ -114,7 +114,7 @@ class NWTree():
|
||||
"""Pack the content of the tree into an XML object.
|
||||
"""
|
||||
xContent = etree.SubElement(xParent, "content", attrib={
|
||||
"count":str(self._theLength)}
|
||||
"count": str(self._theLength)}
|
||||
)
|
||||
for tHandle in self._treeOrder:
|
||||
tItem = self.__getitem__(tHandle)
|
||||
@@ -154,7 +154,7 @@ class NWTree():
|
||||
outFile.write(" Table of Contents\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")
|
||||
for tHandle in sorted(self._treeOrder):
|
||||
tItem = self.__getitem__(tHandle)
|
||||
|
||||
Reference in New Issue
Block a user