From 464c7dae0a7d4a1b1346d909338aeac83d282f93 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 20 Feb 2021 17:27:32 +0100 Subject: [PATCH 1/3] Fix an issue in index with open a version 1.2 project --- nw/core/index.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nw/core/index.py b/nw/core/index.py index 2299ab0d..73d469c4 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -714,7 +714,8 @@ class NWIndex(): for refTitle in self._refIndex[tHandle]: for aTag in self._refIndex[tHandle][refTitle].get("tags", []): if len(aTag) == 3 and (sTitle is None or sTitle == refTitle): - theRefs[aTag[1]].append(aTag[2]) + if aTag[1] in theRefs: # Future-compatible. Check can be removed in 1.2. + theRefs[aTag[1]].append(aTag[2]) return theRefs From dcd4c19b213ef8e743937e4e0d264edb3ef3a664 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 20 Feb 2021 17:28:05 +0100 Subject: [PATCH 2/3] Drop logging quick open and close sessions to the session log --- nw/core/project.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/nw/core/project.py b/nw/core/project.py index a22f7aa9..f06969c8 100644 --- a/nw/core/project.py +++ b/nw/core/project.py @@ -1398,6 +1398,15 @@ class NWProject(): sessionFile = os.path.join(self.projMeta, nwFiles.SESS_STATS) isFile = os.path.isfile(sessionFile) + nowTime = time() + sessDiff = self.getSessionWordCount() + sessTime = nowTime - self.projOpened + + logger.info("The session lasted %d sec and added %d words" % (int(sessTime), sessDiff)) + if sessTime < 300 and sessDiff == 0: + logger.info("Session too short, skipping log entry") + return False + try: with open(sessionFile, mode="a+", encoding="utf8") as outFile: if not isFile: @@ -1410,7 +1419,7 @@ class NWProject(): outFile.write("%-19s %-19s %8d %8d\n" % ( formatTimeStamp(self.projOpened), - formatTimeStamp(time()), + formatTimeStamp(nowTime), self.novelWCount, self.notesWCount, )) From 5977c8c8e29afd14ccd1bb4affb2bfdd1215712d Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Sat, 20 Feb 2021 17:31:31 +0100 Subject: [PATCH 3/3] Fix test --- tests/test_core/test_core_project.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_core/test_core_project.py b/tests/test_core/test_core_project.py index 61c2d25f..2a688a23 100644 --- a/tests/test_core/test_core_project.py +++ b/tests/test_core/test_core_project.py @@ -1073,7 +1073,6 @@ def testCoreProject_OldFormat(dummyGUI, nwOldProj): # Check that new files have been created assert os.path.isfile(os.path.join(nwOldProj, "meta", "guiOptions.json")) - assert os.path.isfile(os.path.join(nwOldProj, "meta", "sessionStats.log")) assert os.path.isfile(os.path.join(nwOldProj, "ToC.txt")) # END Test testCoreProject_OldFormat