Update index check and test
This commit is contained in:
+19
-4
@@ -220,12 +220,9 @@ class NWIndex():
|
||||
self._checkNovelNoteIndex("novelIndex")
|
||||
self._checkNovelNoteIndex("noteIndex")
|
||||
self._checkTextCounts()
|
||||
self._checkFirstTitles()
|
||||
self.indexBroken = False
|
||||
|
||||
for tHandle in self._firstTitle:
|
||||
if len(self._firstTitle[tHandle]) != 2:
|
||||
self.indexBroken = True
|
||||
|
||||
except Exception:
|
||||
logger.error("Error while checking index")
|
||||
nw.logException()
|
||||
@@ -897,4 +894,22 @@ 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
|
||||
|
||||
Reference in New Issue
Block a user