diff --git a/nw/core/index.py b/nw/core/index.py index 6f72bf3b..ac1fba3f 100644 --- a/nw/core/index.py +++ b/nw/core/index.py @@ -59,7 +59,6 @@ class NWIndex(): self._novelIndex = {} self._noteIndex = {} self._textCounts = {} - self._firstTitle = {} # TimeStamps self._timeNovel = 0 @@ -80,7 +79,6 @@ class NWIndex(): self._novelIndex = {} self._noteIndex = {} self._textCounts = {} - self._firstTitle = {} self._timeNovel = 0 self._timeNotes = 0 self._timeIndex = 0 @@ -103,7 +101,6 @@ class NWIndex(): self._novelIndex.pop(tHandle, None) self._noteIndex.pop(tHandle, None) self._textCounts.pop(tHandle, None) - self._firstTitle.pop(tHandle, None) return @@ -172,7 +169,6 @@ class NWIndex(): self._novelIndex = theData.get("novelIndex", {}) self._noteIndex = theData.get("noteIndex", {}) self._textCounts = theData.get("textCounts", {}) - self._firstTitle = theData.get("firstTitle", {}) nowTime = round(time()) self._timeNovel = nowTime @@ -198,7 +194,6 @@ class NWIndex(): "novelIndex" : self._novelIndex, "noteIndex" : self._noteIndex, "textCounts" : self._textCounts, - "firstTitle" : self._firstTitle, }, outFile, indent=2) except Exception: logger.error("Failed to save index file") @@ -220,7 +215,6 @@ class NWIndex(): self._checkNovelNoteIndex("novelIndex") self._checkNovelNoteIndex("noteIndex") self._checkTextCounts() - self._checkFirstTitles() self.indexBroken = False except Exception: @@ -291,7 +285,6 @@ class NWIndex(): "tags" : [], "updated" : round(time()), } - self._firstTitle[tHandle] = ["H0", "T000000"] if itemLayout == nwItemLayout.NOTE: self._novelIndex.pop(tHandle, None) self._noteIndex[tHandle] = {} @@ -400,9 +393,6 @@ class NWIndex(): "updated" : round(time()), } - if self._firstTitle[tHandle][0] == "H0": - self._firstTitle[tHandle] = [hDepth, sTitle] - if hText != "": if isNovel: if tHandle in self._novelIndex: @@ -678,11 +668,6 @@ class NWIndex(): return theToC - def getFirstTitle(self, tHandle): - """Return the level and location of the first title of a handle. - """ - return self._firstTitle.get(tHandle, ["H0", "T000000"]) - def getCounts(self, tHandle, sTitle=None): """Returns the counts for a file, or a section of a file starting at title sTitle if it is provided. @@ -924,22 +909,4 @@ class NWIndex(): return - def _checkFirstTitles(self): - """Scan the first titles index for errors. - Waring: This function raises exceptions. - """ - for tHandle in self._firstTitle: - if not isHandle(tHandle): - raise KeyError("firstTitle key is not a handle") - - tEntry = self._firstTitle[tHandle] - if len(tEntry) != 2: - raise IndexError("firstTitle[a] expected 2 values") - if not tEntry[0] in self.H_VALID: - raise ValueError("firstTitle[a][0] is not a header level") - if not isTitleTag(tEntry[1]): - raise ValueError("firstTitle[a][1] is not a title tag") - - return - # END Class NWIndex diff --git a/sample/nwProject.nwx b/sample/nwProject.nwx index cbb940be..4bc8a637 100644 --- a/sample/nwProject.nwx +++ b/sample/nwProject.nwx @@ -1,13 +1,13 @@ - + Sample Project Sample Project Jane Smith Jay Doh - 881 - 157 - 42668 + 886 + 158 + 42826 False @@ -120,7 +120,7 @@ 1810 318 8 - 1880 + 219 Another Scene diff --git a/tests/reference/coreIndex_LoadSave_tagsIndex.json b/tests/reference/coreIndex_LoadSave_tagsIndex.json index 993b4e26..2aa3df3c 100644 --- a/tests/reference/coreIndex_LoadSave_tagsIndex.json +++ b/tests/reference/coreIndex_LoadSave_tagsIndex.json @@ -567,67 +567,5 @@ 259, 3 ] - }, - "firstTitle": { - "7a992350f3eb6": [ - "H1", - "T000001" - ], - "8c58a65414c23": [ - "H0", - "T000000" - ], - "88d59a277361b": [ - "H2", - "T000001" - ], - "db7e733775d4d": [ - "H1", - "T000001" - ], - "fb609cd8319dc": [ - "H2", - "T000001" - ], - "88243afbe5ed8": [ - "H3", - "T000001" - ], - "f96ec11c6a3da": [ - "H3", - "T000001" - ], - "846352075de7d": [ - "H2", - "T000001" - ], - "441420a886d82": [ - "H2", - "T000001" - ], - "eb103bc70c90c": [ - "H3", - "T000001" - ], - "f8c0562e50f1b": [ - "H3", - "T000001" - ], - "47666c91c7ccf": [ - "H3", - "T000001" - ], - "4c4f28287af27": [ - "H1", - "T000001" - ], - "2426c6f0ca922": [ - "H1", - "T000001" - ], - "04468803b92e1": [ - "H1", - "T000001" - ] } } \ No newline at end of file diff --git a/tests/test_core/test_core_index.py b/tests/test_core/test_core_index.py index 8d4a2e89..9b1c656a 100644 --- a/tests/test_core/test_core_index.py +++ b/tests/test_core/test_core_index.py @@ -591,11 +591,6 @@ def testCoreIndex_ExtractData(nwMinimal, dummyGUI): assert wC == 16 assert pC == 2 - # getFirstTitle - # ============= - - assert theIndex.getFirstTitle(cHandle) == ["H1", "T000001"] - # Novel Stats # =========== @@ -1166,51 +1161,3 @@ def testCoreIndex_CheckTextCounts(dummyGUI): theIndex._checkTextCounts() # END Test testCoreIndex_CheckTextCounts - -@pytest.mark.core -def testCoreIndex_CheckFirstTitle(dummyGUI): - """Test the first title checker. - """ - theProject = NWProject(dummyGUI) - theIndex = NWIndex(theProject, dummyGUI) - - # Valid Index - theIndex._firstTitle = { - "53b69b83cdafc": ["H1", "T000001"], - "974e400180a99": ["H0", "T000000"], - } - assert theIndex._checkFirstTitles() is None - - # Invalid Handle - theIndex._firstTitle = { - "53b69b83cdafc": ["H1", "T000001"], - "h74e400180a99": ["H0", "T000000"], - } - with pytest.raises(KeyError): - theIndex._checkFirstTitles() - - # Wrong Length - theIndex._firstTitle = { - "53b69b83cdafc": ["H1", "T000001"], - "974e400180a99": ["H0", "T000000", "stuff"], - } - with pytest.raises(IndexError): - theIndex._checkFirstTitles() - - # Wrong Header - theIndex._firstTitle = { - "53b69b83cdafc": ["H1", "T000001"], - "974e400180a99": ["XX", "T000000"], - } - with pytest.raises(ValueError): - theIndex._checkFirstTitles() - - # Wrong Title - theIndex._firstTitle = { - "53b69b83cdafc": ["H1", "T000001"], - "974e400180a99": ["H0", "INVALID"], - } - with pytest.raises(ValueError): - theIndex._checkFirstTitles() - -# END Test testCoreIndex_CheckFirstTitle