Drop dictionary alignment by colon
This commit is contained in:
+25
-25
@@ -183,11 +183,11 @@ class NWIndex():
|
||||
try:
|
||||
with open(indexFile, mode="w+", encoding="utf8") as outFile:
|
||||
json.dump({
|
||||
"tagIndex" : self._tagIndex,
|
||||
"refIndex" : self._refIndex,
|
||||
"novelIndex" : self._novelIndex,
|
||||
"noteIndex" : self._noteIndex,
|
||||
"textCounts" : self._textCounts,
|
||||
"tagIndex": self._tagIndex,
|
||||
"refIndex": self._refIndex,
|
||||
"novelIndex": self._novelIndex,
|
||||
"noteIndex": self._noteIndex,
|
||||
"textCounts": self._textCounts,
|
||||
}, outFile, indent=2)
|
||||
except Exception:
|
||||
logger.error("Failed to save index file")
|
||||
@@ -272,8 +272,8 @@ class NWIndex():
|
||||
# Also add a default entry T000000 in case the file has no title
|
||||
self._refIndex[tHandle] = {}
|
||||
self._refIndex[tHandle]["T000000"] = {
|
||||
"tags" : [],
|
||||
"updated" : round(time()),
|
||||
"tags": [],
|
||||
"updated": round(time()),
|
||||
}
|
||||
if itemLayout == nwItemLayout.NOTE:
|
||||
self._novelIndex.pop(tHandle, None)
|
||||
@@ -367,18 +367,18 @@ class NWIndex():
|
||||
|
||||
sTitle = "T%06d" % nLine
|
||||
self._refIndex[tHandle][sTitle] = {
|
||||
"tags" : [],
|
||||
"updated" : round(time()),
|
||||
"tags": [],
|
||||
"updated": round(time()),
|
||||
}
|
||||
theData = {
|
||||
"level" : hDepth,
|
||||
"title" : hText,
|
||||
"layout" : itemLayout.name,
|
||||
"synopsis" : "",
|
||||
"cCount" : 0,
|
||||
"wCount" : 0,
|
||||
"pCount" : 0,
|
||||
"updated" : round(time()),
|
||||
"level": hDepth,
|
||||
"title": hText,
|
||||
"layout": itemLayout.name,
|
||||
"synopsis": "",
|
||||
"cCount": 0,
|
||||
"wCount": 0,
|
||||
"pCount": 0,
|
||||
"updated": round(time()),
|
||||
}
|
||||
|
||||
if hText != "":
|
||||
@@ -395,14 +395,14 @@ class NWIndex():
|
||||
"""Index a page with no title.
|
||||
"""
|
||||
theData = {
|
||||
"level" : "H0",
|
||||
"title" : "Untitled Page",
|
||||
"layout" : itemLayout.name,
|
||||
"synopsis" : "",
|
||||
"cCount" : 0,
|
||||
"wCount" : 0,
|
||||
"pCount" : 0,
|
||||
"updated" : round(time()),
|
||||
"level": "H0",
|
||||
"title": "Untitled Page",
|
||||
"layout": itemLayout.name,
|
||||
"synopsis": "",
|
||||
"cCount": 0,
|
||||
"wCount": 0,
|
||||
"pCount": 0,
|
||||
"updated": round(time()),
|
||||
}
|
||||
|
||||
if isNovel:
|
||||
|
||||
+3
-3
@@ -67,9 +67,9 @@ class NWItem():
|
||||
"""Packs all the data in the class instance into an XML object.
|
||||
"""
|
||||
xPack = etree.SubElement(xParent, "item", attrib={
|
||||
"handle" : str(self.itemHandle),
|
||||
"order" : str(self.itemOrder),
|
||||
"parent" : str(self.itemParent),
|
||||
"handle": str(self.itemHandle),
|
||||
"order": str(self.itemOrder),
|
||||
"parent": str(self.itemParent),
|
||||
})
|
||||
self._subPack(xPack, "name", text=str(self.itemName))
|
||||
self._subPack(xPack, "type", text=str(self.itemType.name))
|
||||
|
||||
+9
-9
@@ -203,11 +203,11 @@ class NWProject():
|
||||
self.bookAuthors = []
|
||||
self.autoReplace = {}
|
||||
self.titleFormat = {
|
||||
"title" : r"%title%",
|
||||
"chapter" : self.tr("Chapter")+r" %ch%: %title%",
|
||||
"unnumbered" : r"%title%",
|
||||
"scene" : r"* * *",
|
||||
"section" : r"",
|
||||
"title": "%title%",
|
||||
"chapter": self.tr("Chapter")+" %ch%: %title%",
|
||||
"unnumbered": "%title%",
|
||||
"scene": "* * *",
|
||||
"section": "",
|
||||
}
|
||||
self.spellCheck = False
|
||||
self.autoOutline = True
|
||||
@@ -620,10 +620,10 @@ class NWProject():
|
||||
# Root element and project details
|
||||
logger.debug("Writing project meta")
|
||||
nwXML = etree.Element("novelWriterXML", attrib={
|
||||
"appVersion" : str(nw.__version__),
|
||||
"hexVersion" : str(nw.__hexversion__),
|
||||
"fileVersion" : "1.2",
|
||||
"timeStamp" : formatTimeStamp(saveTime),
|
||||
"appVersion": str(nw.__version__),
|
||||
"hexVersion": str(nw.__hexversion__),
|
||||
"fileVersion": "1.2",
|
||||
"timeStamp": formatTimeStamp(saveTime),
|
||||
})
|
||||
|
||||
editTime = int(self.editTime + saveTime - self.projOpened)
|
||||
|
||||
+3
-3
@@ -122,9 +122,9 @@ class NWStatus():
|
||||
"""
|
||||
for n in range(self._theLength):
|
||||
xSub = etree.SubElement(xParent, "entry", attrib={
|
||||
"blue" : str(self._theColours[n][2]),
|
||||
"green" : str(self._theColours[n][1]),
|
||||
"red" : str(self._theColours[n][0]),
|
||||
"blue": str(self._theColours[n][2]),
|
||||
"green": str(self._theColours[n][1]),
|
||||
"red": str(self._theColours[n][0]),
|
||||
})
|
||||
xSub.text = self._theLabels[n]
|
||||
return True
|
||||
|
||||
+17
-17
@@ -82,9 +82,9 @@ class ToHtml(Tokenizer):
|
||||
# must take this into account when parsing for markup using
|
||||
# angle brackets.
|
||||
self._trMap = str.maketrans({
|
||||
"<" : "<",
|
||||
">" : ">",
|
||||
"&" : "&",
|
||||
"<": "<",
|
||||
">": ">",
|
||||
"&": "&",
|
||||
})
|
||||
|
||||
if doReplace:
|
||||
@@ -115,22 +115,22 @@ class ToHtml(Tokenizer):
|
||||
to theResult.
|
||||
"""
|
||||
if self.genMode == self.M_PREVIEW:
|
||||
htmlTags = { # HTML4 + CSS2
|
||||
self.FMT_B_B : "<b>",
|
||||
self.FMT_B_E : "</b>",
|
||||
self.FMT_I_B : "<i>",
|
||||
self.FMT_I_E : "</i>",
|
||||
self.FMT_D_B : "<span style='text-decoration: line-through;'>",
|
||||
self.FMT_D_E : "</span>",
|
||||
htmlTags = { # HTML4 + CSS2
|
||||
self.FMT_B_B: "<b>",
|
||||
self.FMT_B_E: "</b>",
|
||||
self.FMT_I_B: "<i>",
|
||||
self.FMT_I_E: "</i>",
|
||||
self.FMT_D_B: "<span style='text-decoration: line-through;'>",
|
||||
self.FMT_D_E: "</span>",
|
||||
}
|
||||
else:
|
||||
htmlTags = { # HTML5
|
||||
self.FMT_B_B : "<strong>",
|
||||
self.FMT_B_E : "</strong>",
|
||||
self.FMT_I_B : "<em>",
|
||||
self.FMT_I_E : "</em>",
|
||||
self.FMT_D_B : "<del>",
|
||||
self.FMT_D_E : "</del>",
|
||||
htmlTags = { # HTML5
|
||||
self.FMT_B_B: "<strong>",
|
||||
self.FMT_B_E: "</strong>",
|
||||
self.FMT_I_B: "<em>",
|
||||
self.FMT_I_E: "</em>",
|
||||
self.FMT_D_B: "<del>",
|
||||
self.FMT_D_E: "</del>",
|
||||
}
|
||||
|
||||
if self.isNovel and self.genMode != self.M_PREVIEW:
|
||||
|
||||
@@ -341,9 +341,9 @@ class Tokenizer():
|
||||
does the standard escaped characters.
|
||||
"""
|
||||
escapeDict = {
|
||||
r"\*" : "*",
|
||||
r"\~" : "~",
|
||||
r"\_" : "_",
|
||||
r"\*": "*",
|
||||
r"\~": "~",
|
||||
r"\_": "_",
|
||||
}
|
||||
escReplace = re.compile(
|
||||
"|".join([re.escape(k) for k in escapeDict.keys()]), flags=re.DOTALL
|
||||
|
||||
+6
-6
@@ -72,16 +72,16 @@ class ToMarkdown(Tokenizer):
|
||||
if self.genMode == self.M_STD:
|
||||
# Standard
|
||||
mdTags = {
|
||||
self.FMT_B_B : "**", self.FMT_B_E : "**",
|
||||
self.FMT_I_B : "_", self.FMT_I_E : "_",
|
||||
self.FMT_D_B : "", self.FMT_D_E : "",
|
||||
self.FMT_B_B: "**", self.FMT_B_E: "**",
|
||||
self.FMT_I_B: "_", self.FMT_I_E: "_",
|
||||
self.FMT_D_B: "", self.FMT_D_E: "",
|
||||
}
|
||||
else:
|
||||
# GitHub
|
||||
mdTags = {
|
||||
self.FMT_B_B : "**", self.FMT_B_E : "**",
|
||||
self.FMT_I_B : "_", self.FMT_I_E : "_",
|
||||
self.FMT_D_B : "~~", self.FMT_D_E : "~~",
|
||||
self.FMT_B_B: "**", self.FMT_B_E: "**",
|
||||
self.FMT_I_B: "_", self.FMT_I_E: "_",
|
||||
self.FMT_D_B: "~~", self.FMT_D_E: "~~",
|
||||
}
|
||||
|
||||
self.theResult = ""
|
||||
|
||||
+14
-14
@@ -38,12 +38,12 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
# Main XML NameSpaces
|
||||
XML_NS = {
|
||||
"office" : "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
|
||||
"style" : "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
|
||||
"loext" : "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0",
|
||||
"text" : "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
|
||||
"meta" : "urn:oasis:names:tc:opendocument:xmlns:meta:1.0",
|
||||
"fo" : "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",
|
||||
"office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0",
|
||||
"style": "urn:oasis:names:tc:opendocument:xmlns:style:1.0",
|
||||
"loext": "urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0",
|
||||
"text": "urn:oasis:names:tc:opendocument:xmlns:text:1.0",
|
||||
"meta": "urn:oasis:names:tc:opendocument:xmlns:meta:1.0",
|
||||
"fo": "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",
|
||||
}
|
||||
|
||||
# Mimetype and Version
|
||||
@@ -318,12 +318,12 @@ class ToOdt(Tokenizer):
|
||||
self.theResult = "" # Not used, but cleared just in case
|
||||
|
||||
odtTags = {
|
||||
self.FMT_B_B : "_B", # Bold open format
|
||||
self.FMT_B_E : "b_", # Bold close format
|
||||
self.FMT_I_B : "I", # Italic open format
|
||||
self.FMT_I_E : "i", # Italic close format
|
||||
self.FMT_D_B : "_S", # Strikethrough open format
|
||||
self.FMT_D_E : "s_", # Strikethrough close format
|
||||
self.FMT_B_B: "_B", # Bold open format
|
||||
self.FMT_B_E: "b_", # Bold close format
|
||||
self.FMT_I_B: "I", # Italic open format
|
||||
self.FMT_I_E: "i", # Italic close format
|
||||
self.FMT_D_B: "_S", # Strikethrough open format
|
||||
self.FMT_D_E: "s_", # Strikethrough close format
|
||||
}
|
||||
|
||||
thisPar = []
|
||||
@@ -459,7 +459,7 @@ class ToOdt(Tokenizer):
|
||||
def saveOpenDocText(self, savePath):
|
||||
"""Save the data to an .odt file.
|
||||
"""
|
||||
mMap = {"manifest" : "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"}
|
||||
mMap = {"manifest": "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"}
|
||||
mMani = "{%s}manifest" % mMap["manifest"]
|
||||
mVers = "{%s}version" % mMap["manifest"]
|
||||
mPath = "{%s}full-path" % mMap["manifest"]
|
||||
@@ -473,7 +473,7 @@ class ToOdt(Tokenizer):
|
||||
etree.SubElement(xMani, mFile, attrib={mPath: "meta.xml", mType: "text/xml"})
|
||||
etree.SubElement(xMani, mFile, attrib={mPath: "styles.xml", mType: "text/xml"})
|
||||
|
||||
sMap = {"office" : "urn:oasis:names:tc:opendocument:xmlns:office:1.0"}
|
||||
sMap = {"office": "urn:oasis:names:tc:opendocument:xmlns:office:1.0"}
|
||||
oRoot = "{%s}document-settings" % sMap["office"]
|
||||
oSett = "{%s}settings" % sMap["office"]
|
||||
xSett = etree.Element(oRoot, nsmap=sMap)
|
||||
|
||||
Reference in New Issue
Block a user