Fixed flake8 W and F errors

This commit is contained in:
Veronica K. B. Olsen
2020-08-12 21:41:37 +02:00
parent 72cb1ed60f
commit 00f0a6887c
22 changed files with 41 additions and 72 deletions
-3
View File
@@ -27,7 +27,6 @@
import logging
import json
import nw
from os import path
from time import time
@@ -603,8 +602,6 @@ class NWIndex():
by tHandle.
"""
theRefs = {}
tItem = self.theProject.projTree[tHandle]
if tHandle is None:
return theRefs
+14 -15
View File
@@ -26,7 +26,6 @@
"""
import logging
import nw
from lxml import etree
@@ -73,19 +72,19 @@ class NWItem():
"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))
self._subPack(xPack, "name", text=str(self.itemName))
self._subPack(xPack, "type", text=str(self.itemType.name))
self._subPack(xPack, "class", text=str(self.itemClass.name))
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)
self._subPack(xPack, "exported", text=str(self.isExported))
self._subPack(xPack, "layout", text=str(self.itemLayout.name))
self._subPack(xPack, "charCount", text=str(self.charCount), none=False)
self._subPack(xPack, "wordCount", text=str(self.wordCount), none=False)
self._subPack(xPack, "paraCount", text=str(self.paraCount), none=False)
self._subPack(xPack, "cursorPos", text=str(self.cursorPos), none=False)
else:
xSub = self._subPack(xPack, "expanded", text=str(self.isExpanded))
self._subPack(xPack, "expanded", text=str(self.isExpanded))
return
def unpackXML(self, xItem):
@@ -135,7 +134,7 @@ class NWItem():
xSub = etree.SubElement(xParent, name, attrib=attrib)
if text is not None:
xSub.text = text
return xSub
return
##
# Set Item Values
@@ -235,7 +234,7 @@ class NWItem():
if isinstance(expState, str):
self.isExpanded = (expState == str(True))
else:
self.isExpanded = (expState == True) # noqa
self.isExpanded = (expState == True) # noqa: E712
return
def setExported(self, expState):
@@ -244,7 +243,7 @@ class NWItem():
if isinstance(expState, str):
self.isExported = (expState == str(True))
else:
self.isExported = (expState == True) # noqa
self.isExported = (expState == True) # noqa: E712
return
##
+14 -15
View File
@@ -26,7 +26,6 @@
"""
import logging
import json
import nw
from os import path, mkdir, listdir, unlink, rename, rmdir
@@ -265,27 +264,28 @@ class NWProject():
if popMinimal:
# Creating a minimal project with a few root folders and a
# single chapter folder with a single file.
nHandle = self.newRoot("Novel", nwItemClass.NOVEL)
xHandle = self.newRoot("Plot", nwItemClass.PLOT)
xHandle = self.newRoot("Characters", nwItemClass.CHARACTER)
xHandle = self.newRoot("World", nwItemClass.WORLD)
tHandle = self.newFile("Title Page", nwItemClass.NOVEL, nHandle)
dHandle = self.newFolder("New Chapter", nwItemClass.NOVEL, nHandle)
cHandle = self.newFile("New Chapter", nwItemClass.NOVEL, dHandle)
sHandle = self.newFile("New Scene", nwItemClass.NOVEL, dHandle)
xHandle = {}
xHandle[1] = self.newRoot("Novel", nwItemClass.NOVEL)
xHandle[2] = self.newRoot("Plot", nwItemClass.PLOT)
xHandle[3] = self.newRoot("Characters", nwItemClass.CHARACTER)
xHandle[4] = self.newRoot("World", nwItemClass.WORLD)
xHandle[5] = self.newFile("Title Page", nwItemClass.NOVEL, xHandle[1])
xHandle[6] = self.newFolder("New Chapter", nwItemClass.NOVEL, xHandle[1])
xHandle[7] = self.newFile("New Chapter", nwItemClass.NOVEL, xHandle[6])
xHandle[8] = self.newFile("New Scene", nwItemClass.NOVEL, xHandle[6])
self.projTree.setFileItemLayout(tHandle, nwItemLayout.TITLE)
self.projTree.setFileItemLayout(cHandle, nwItemLayout.CHAPTER)
self.projTree.setFileItemLayout(xHandle[5], nwItemLayout.TITLE)
self.projTree.setFileItemLayout(xHandle[7], nwItemLayout.CHAPTER)
aDoc.openDocument(tHandle, showStatus=False)
aDoc.openDocument(xHandle[5], showStatus=False)
aDoc.saveDocument(titlePage)
aDoc.clearDocument()
aDoc.openDocument(cHandle, showStatus=False)
aDoc.openDocument(xHandle[7], showStatus=False)
aDoc.saveDocument("## New Chapter\n\n")
aDoc.clearDocument()
aDoc.openDocument(sHandle, showStatus=False)
aDoc.openDocument(xHandle[8], showStatus=False)
aDoc.saveDocument("### New Scene\n\n")
aDoc.clearDocument()
@@ -838,7 +838,6 @@ class NWProject():
project path, or if the folder doesn't exist, look for the zip
file in the assets folder.
"""
projName = projData.get("projName", "Sample Project")
projPath = projData.get("projPath", None)
if projPath is None:
logger.error("No project path set for the example project")
+1 -1
View File
@@ -197,7 +197,7 @@ class NWSpellEnchantDummy:
"""
def __init__(self):
return
def check(self, theWord):
return True
-1
View File
@@ -26,7 +26,6 @@
"""
import logging
import nw
from lxml import etree
-7
View File
@@ -27,7 +27,6 @@
import logging
import re
import nw
from nw.core.tokenizer import Tokenizer
from nw.constants import nwUnicode, nwLabels, nwKeyWords
@@ -153,12 +152,6 @@ class ToHtml(Tokenizer):
h3 = "h3"
h4 = "h4"
alignHead = self.A_LEFT
if self.doJustify:
alignPar = self.A_JUSTIFY
else:
alignPar = self.A_LEFT
self.theResult = ""
thisPar = []
-1
View File
@@ -28,7 +28,6 @@
"""
import logging
import nw
logger = logging.getLogger(__name__)
-1
View File
@@ -27,7 +27,6 @@
import logging
import json
import nw
from os import path
from lxml import etree