diff --git a/nw/core/project.py b/nw/core/project.py index b163cbd1..f7e412db 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -331,6 +331,8 @@ class NWProject(): hexVersion = xRoot.attrib["hexVersion"] if "fileVersion" in xRoot.attrib: fileVersion = xRoot.attrib["fileVersion"] + + # The following are deprecated and will be removed if "saveCount" in xRoot.attrib: self.saveCount = checkInt(xRoot.attrib["saveCount"], 0, False) if "autoCount" in xRoot.attrib: @@ -409,6 +411,14 @@ class NWProject(): elif xItem.tag == "author": logger.verbose("Author: '%s'" % xItem.text) self.bookAuthors.append(xItem.text) + elif xItem.tag == "saveCount": + self.saveCount = checkInt(xItem.text, 0) + elif xItem.tag == "autoCount": + self.autoCount = checkInt(xItem.text, 0) + elif xItem.tag == "editTime": + self.editTime = checkInt(xItem.text, 0) + + # The following is deprecated, and will be removed elif xItem.tag == "backup": self.doBackup = checkBool(xItem.text, False) @@ -417,7 +427,9 @@ class NWProject(): for xItem in xChild: if xItem.text is None: continue - if xItem.tag == "spellCheck": + if xItem.tag == "doBackup": + self.doBackup = checkBool(xItem.text, False) + elif xItem.tag == "spellCheck": self.spellCheck = checkBool(xItem.text, False) elif xItem.tag == "autoOutline": self.autoOutline = checkBool(xItem.text, True) @@ -489,21 +501,23 @@ class NWProject(): "appVersion" : str(nw.__version__), "hexVersion" : str(nw.__hexversion__), "fileVersion" : "1.1", - "saveCount" : str(self.saveCount), - "autoCount" : str(self.autoCount), "timeStamp" : formatTimeStamp(saveTime), - "editTime" : str(int(self.editTime + saveTime - self.projOpened)), }) + editTime = int(self.editTime + saveTime - self.projOpened) + # Save Project Meta xProject = etree.SubElement(nwXML, "project") self._packProjectValue(xProject, "name", self.projName, True) self._packProjectValue(xProject, "title", self.bookTitle, True) self._packProjectValue(xProject, "author", self.bookAuthors) - self._packProjectValue(xProject, "backup", self.doBackup) + self._packProjectValue(xProject, "saveCount", str(self.saveCount)) + self._packProjectValue(xProject, "autoCount", str(self.autoCount)) + self._packProjectValue(xProject, "editTime", str(editTime)) # Save Project Settings xSettings = etree.SubElement(nwXML, "settings") + self._packProjectValue(xSettings, "doBackup", self.doBackup) self._packProjectValue(xSettings, "spellCheck", self.spellCheck) self._packProjectValue(xSettings, "autoOutline", self.autoOutline) self._packProjectValue(xSettings, "lastEdited", self.lastEdited) diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx index b7b0bde0..88ce6d2f 100644 --- a/sample/nwProject.nwx +++ b/sample/nwProject.nwx @@ -1,13 +1,16 @@ - + Sample Project Sample Project Jane Smith Jay Doh - False + 273 + 40 + 4125 + False True True 636b6aa9b697b @@ -24,9 +27,6 @@ %title% Scene %ch%.%sc%: %title%
- True - True - False New diff --git a/tests/reference/gui/0_nwProject.nwx b/tests/reference/gui/0_nwProject.nwx index c564337a..63535bfa 100644 --- a/tests/reference/gui/0_nwProject.nwx +++ b/tests/reference/gui/0_nwProject.nwx @@ -1,11 +1,14 @@ - + New Project - True + 2 + 1 + 0 + True False True None diff --git a/tests/reference/gui/1_nwProject.nwx b/tests/reference/gui/1_nwProject.nwx index db077dde..17180919 100644 --- a/tests/reference/gui/1_nwProject.nwx +++ b/tests/reference/gui/1_nwProject.nwx @@ -1,11 +1,14 @@ - + New Project - True + 5 + 1 + 11 + True True True 31489056e0916 diff --git a/tests/reference/gui/2_nwProject.nwx b/tests/reference/gui/2_nwProject.nwx index 1f63cb60..316e30c1 100644 --- a/tests/reference/gui/2_nwProject.nwx +++ b/tests/reference/gui/2_nwProject.nwx @@ -1,13 +1,16 @@ - + Project Name Project Title Jane Doe John Doh - True + 2 + 1 + 1 + True False True None diff --git a/tests/reference/gui/3_nwProject.nwx b/tests/reference/gui/3_nwProject.nwx index 88a00d4b..7ae01352 100644 --- a/tests/reference/gui/3_nwProject.nwx +++ b/tests/reference/gui/3_nwProject.nwx @@ -1,11 +1,14 @@ - + New Project - True + 2 + 1 + 0 + True False True None diff --git a/tests/reference/proj/1_nwProject.nwx b/tests/reference/proj/1_nwProject.nwx index 8156cf1e..8516baae 100644 --- a/tests/reference/proj/1_nwProject.nwx +++ b/tests/reference/proj/1_nwProject.nwx @@ -1,11 +1,14 @@ - + New Project - True + 1 + 0 + 0 + True False True None diff --git a/tests/reference/proj/2_nwProject.nwx b/tests/reference/proj/2_nwProject.nwx index b8e454d6..da82f956 100644 --- a/tests/reference/proj/2_nwProject.nwx +++ b/tests/reference/proj/2_nwProject.nwx @@ -1,11 +1,14 @@ - + New Project - True + 4 + 0 + 0 + True False True None diff --git a/tests/reference/proj/3_nwProject.nwx b/tests/reference/proj/3_nwProject.nwx index 130933e0..8adfadb8 100644 --- a/tests/reference/proj/3_nwProject.nwx +++ b/tests/reference/proj/3_nwProject.nwx @@ -1,11 +1,14 @@ - + New Project - True + 5 + 0 + 0 + True False True None diff --git a/tests/test_gui.py b/tests/test_gui.py index fe52cabd..cd375cd8 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -45,7 +45,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef, nwTemp): # Check the files projFile = path.join(nwTempGUI,"nwProject.nwx") - assert cmpFiles(projFile, path.join(nwRef,"gui","0_nwProject.nwx"), [2]) + assert cmpFiles(projFile, path.join(nwRef,"gui","0_nwProject.nwx"), [2, 6, 7, 8]) qtbot.wait(stepDelay) # qtbot.stopForInteraction() @@ -246,7 +246,7 @@ def testMainWindows(qtbot, nwTempGUI, nwRef, nwTemp): # Check the files refFile = path.join(nwTempGUI, "nwProject.nwx") - assert cmpFiles(refFile, path.join(nwRef, "gui", "1_nwProject.nwx"), [2]) + assert cmpFiles(refFile, path.join(nwRef, "gui", "1_nwProject.nwx"), [2, 6, 7, 8]) refFile = path.join(nwTempGUI, "content", "0e17daca5f3e1.nwd") assert cmpFiles(refFile, path.join(nwRef, "gui", "1_0e17daca5f3e1.nwd")) refFile = path.join(nwTempGUI, "content", "98010bd9270f9.nwd") @@ -342,7 +342,7 @@ def testProjectEditor(qtbot, nwTempGUI, nwRef, nwTemp): # Check the files projFile = path.join(nwTempGUI,"nwProject.nwx") - assert cmpFiles(projFile, path.join(nwRef, "gui", "2_nwProject.nwx"), [2]) + assert cmpFiles(projFile, path.join(nwRef, "gui", "2_nwProject.nwx"), [2, 8, 9, 10]) nwGUI.closeMain() # qtbot.stopForInteraction() @@ -391,7 +391,7 @@ def testItemEditor(qtbot, nwTempGUI, nwRef, nwTemp): # Check the files projFile = path.join(nwTempGUI,"nwProject.nwx") - assert cmpFiles(projFile, path.join(nwRef, "gui", "3_nwProject.nwx"), [2]) + assert cmpFiles(projFile, path.join(nwRef, "gui", "3_nwProject.nwx"), [2, 6, 7, 8]) nwGUI.closeMain() # qtbot.stopForInteraction() diff --git a/tests/test_project.py b/tests/test_project.py index 44821856..a4ae401e 100644 --- a/tests/test_project.py +++ b/tests/test_project.py @@ -30,7 +30,7 @@ def testProjectNew(nwTempProj,nwRef,nwTemp): assert theProject.setProjectPath(nwTempProj) assert theProject.saveProject() assert theProject.closeProject() - assert cmpFiles(projFile, refFile, [2]) + assert cmpFiles(projFile, refFile, [2, 6, 7, 8]) @pytest.mark.project def testProjectOpen(nwTempProj): @@ -43,7 +43,7 @@ def testProjectSave(nwTempProj,nwRef): refFile = path.join(nwRef,"proj","1_nwProject.nwx") assert theProject.saveProject() assert theProject.closeProject() - assert cmpFiles(projFile, refFile, [2]) + assert cmpFiles(projFile, refFile, [2, 6, 7, 8]) assert not theProject.projChanged @pytest.mark.project @@ -55,7 +55,7 @@ def testProjectOpenTwice(nwTempProj,nwRef): assert theProject.openProject(projFile, overrideLock=True) assert theProject.saveProject() assert theProject.closeProject() - assert cmpFiles(projFile, refFile, [2]) + assert cmpFiles(projFile, refFile, [2, 6, 7, 8]) @pytest.mark.project def testProjectNewRoot(nwTempProj,nwRef): @@ -73,7 +73,7 @@ def testProjectNewRoot(nwTempProj,nwRef): assert theProject.projChanged assert theProject.saveProject() assert theProject.closeProject() - assert cmpFiles(projFile, refFile, [2]) + assert cmpFiles(projFile, refFile, [2, 6, 7, 8]) assert not theProject.projChanged @pytest.mark.project @@ -86,7 +86,7 @@ def testProjectNewFile(nwTempProj,nwRef): assert theProject.projChanged assert theProject.saveProject() assert theProject.closeProject() - assert cmpFiles(projFile, refFile, [2]) + assert cmpFiles(projFile, refFile, [2, 6, 7, 8]) assert not theProject.projChanged @pytest.mark.project