Merge branch 'main' into merge_1.6.2

This commit is contained in:
Veronica Berglyd Olsen
2022-03-20 15:58:36 +01:00
31 changed files with 692 additions and 1451 deletions
+5 -5
View File
@@ -60,9 +60,9 @@ __license__ = "GPLv3"
__author__ = "Veronica Berglyd Olsen"
__maintainer__ = "Veronica Berglyd Olsen"
__email__ = "code@vkbo.net"
__version__ = "1.6.2"
__hexversion__ = "0x010602f0"
__date__ = "2022-03-20"
__version__ = "1.7-alpha0"
__hexversion__ = "0x010700a0"
__date__ = "2022-02-20"
__status__ = "Stable"
__domain__ = "novelwriter.io"
__url__ = "https://novelwriter.io"
@@ -209,9 +209,9 @@ def main(sysArgs=None):
# Check Packages and Versions
errorData = []
errorCode = 0
if sys.hexversion < 0x030600f0:
if sys.hexversion < 0x030700f0:
errorData.append(
"At least Python 3.6 is required, found %s" % CONFIG.verPyString
"At least Python 3.7 is required, found %s" % CONFIG.verPyString
)
errorCode |= 0x04
if CONFIG.verQtValue < 50300:
-13
View File
@@ -241,19 +241,6 @@ def formatTime(tS):
return "ERROR"
def parseTimeStamp(theStamp, default, allowNone=False):
"""Parses a text representation of a timestamp and converts it into
a float. Note that negative timestamps cause an OSError on Windows.
See https://bugs.python.org/issue29097
"""
if str(theStamp).lower() == "none" and allowNone:
return None
try:
return datetime.strptime(theStamp, nwConst.FMT_TSTAMP).timestamp()
except Exception:
return default
# =============================================================================================== #
# String Functions
# =============================================================================================== #
+40 -23
View File
@@ -139,24 +139,32 @@ class NWItem():
def packXML(self, xParent):
"""Pack all the data in the class instance into an XML object.
"""
xPack = etree.SubElement(xParent, "item", attrib={
"handle": str(self._handle),
"order": str(self._order),
"parent": str(self._parent),
})
self._subPack(xPack, "name", text=str(self._name))
self._subPack(xPack, "type", text=str(self._type.name))
self._subPack(xPack, "class", text=str(self._class.name))
self._subPack(xPack, "status", text=str(self._status))
itemAttrib = {}
itemAttrib["handle"] = str(self._handle)
itemAttrib["parent"] = str(self._parent)
itemAttrib["order"] = str(self._order)
itemAttrib["type"] = str(self._type.name)
itemAttrib["class"] = str(self._class.name)
if self._type == nwItemType.FILE:
self._subPack(xPack, "exported", text=str(self._exported))
self._subPack(xPack, "layout", text=str(self._layout.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)
itemAttrib["layout"] = str(self._layout.name)
metaAttrib = {}
if self._type == nwItemType.FILE:
metaAttrib["charCount"] = str(self._charCount)
metaAttrib["wordCount"] = str(self._wordCount)
metaAttrib["paraCount"] = str(self._paraCount)
metaAttrib["cursorPos"] = str(self._cursorPos)
else:
self._subPack(xPack, "expanded", text=str(self._expanded))
metaAttrib["expanded"] = str(self._expanded)
nameAttrib = {}
nameAttrib["status"] = str(self._status)
if self._type == nwItemType.FILE:
nameAttrib["exported"] = str(self._exported)
xPack = etree.SubElement(xParent, "item", attrib=itemAttrib)
self._subPack(xPack, "meta", attrib=metaAttrib)
self._subPack(xPack, "name", text=str(self._name), attrib=nameAttrib)
return
@@ -175,19 +183,31 @@ class NWItem():
self.setParent(xItem.attrib.get("parent", None))
self.setOrder(xItem.attrib.get("order", 0))
self.setType(xItem.attrib.get("type", None))
self.setClass(xItem.attrib.get("class", None))
self.setLayout(xItem.attrib.get("layout", None))
tmpStatus = ""
for xValue in xItem:
if xValue.tag == "name":
if xValue.tag == "meta":
self.setExpanded(xValue.attrib.get("expanded", False))
self.setCharCount(xValue.attrib.get("charCount", 0))
self.setWordCount(xValue.attrib.get("wordCount", 0))
self.setParaCount(xValue.attrib.get("paraCount", 0))
self.setCursorPos(xValue.attrib.get("cursorPos", 0))
elif xValue.tag == "name":
self.setName(xValue.text)
self.setStatus(xValue.attrib.get("status", None))
self.setExported(xValue.attrib.get("exported", True))
# Legacy Format (1.3 and earlier)
elif xValue.tag == "status":
self.setStatus(xValue.text)
elif xValue.tag == "type":
self.setType(xValue.text)
elif xValue.tag == "class":
self.setClass(xValue.text)
elif xValue.tag == "layout":
self.setLayout(xValue.text)
elif xValue.tag == "status":
tmpStatus = xValue.text
elif xValue.tag == "expanded":
self.setExpanded(xValue.text)
elif xValue.tag == "exported":
@@ -206,9 +226,6 @@ class NWItem():
# version of novelWriter that doesn't know the tag
logger.error("Unknown tag '%s'", xValue.tag)
# Guarantees that <status> is parsed after <class>
self.setStatus(tmpStatus)
return True
@staticmethod
+5 -2
View File
@@ -53,7 +53,7 @@ logger = logging.getLogger(__name__)
class NWProject():
FILE_VERSION = "1.3"
FILE_VERSION = "1.4"
def __init__(self, theParent):
@@ -479,8 +479,11 @@ class NWProject():
# 1.3 : Reduces the number of layouts to only two. One for novel
# documents and one for project notes. Introduced in
# version 1.5.
# 1.4 : Introduces a more compact format for storing items. All
# settings aside from name are now attributes. Introduced
# in version 1.7.
if fileVersion not in ("1.0", "1.1", "1.2", "1.3"):
if fileVersion not in ("1.0", "1.1", "1.2", "1.3", "1.4"):
self.theParent.makeAlert(self.tr(
"Unknown or unsupported novelWriter project file format. "
"The project cannot be opened by this version of novelWriter. "
+1 -1
View File
@@ -330,7 +330,7 @@ class ToOdt(Tokenizer):
# Meta Data
xMeta = etree.SubElement(self._xMeta, _mkTag("meta", "creation-date"))
xMeta.text = datetime.now().strftime(r"%Y-%m-%dT%H:%M:%S")
xMeta.text = datetime.now().isoformat(sep="T", timespec="seconds")
xMeta = etree.SubElement(self._xMeta, _mkTag("meta", "generator"))
xMeta.text = f"novelWriter/{novelwriter.__version__}"
+2 -6
View File
@@ -457,12 +457,8 @@ class GuiWritingStats(QDialog):
if len(inData) < 6:
continue
dStart = datetime.strptime(
"%s %s" % (inData[0], inData[1]), nwConst.FMT_TSTAMP
)
dEnd = datetime.strptime(
"%s %s" % (inData[2], inData[3]), nwConst.FMT_TSTAMP
)
dStart = datetime.fromisoformat(" ".join(inData[0:2]))
dEnd = datetime.fromisoformat(" ".join(inData[2:4]))
sIdle = 0
if len(inData) > 6: