Merge branch 'testing' into release_1.2rc1
This commit is contained in:
@@ -0,0 +1,12 @@
|
|||||||
|
# These are supported funding model platforms
|
||||||
|
|
||||||
|
# github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||||
|
# patreon: # Replace with a single Patreon username
|
||||||
|
# open_collective: # Replace with a single Open Collective username
|
||||||
|
ko_fi: jadzia626
|
||||||
|
# tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||||
|
# community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||||
|
# liberapay: # Replace with a single Liberapay username
|
||||||
|
# issuehunt: # Replace with a single IssueHunt username
|
||||||
|
# otechie: # Replace with a single Otechie username
|
||||||
|
# custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||||
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Python Setup
|
- name: Python Setup
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3
|
python-version: 3
|
||||||
architecture: x64
|
architecture: x64
|
||||||
|
|||||||
+15
-21
@@ -321,8 +321,7 @@ class NWIndex():
|
|||||||
nTitle = nLine
|
nTitle = nLine
|
||||||
|
|
||||||
elif aLine.startswith("@"):
|
elif aLine.startswith("@"):
|
||||||
self._indexNoteRef(tHandle, aLine, nLine, nTitle)
|
self._indexKeyword(tHandle, aLine, nLine, nTitle, itemClass)
|
||||||
self._indexTag(tHandle, aLine, nLine, nTitle, itemClass)
|
|
||||||
|
|
||||||
elif aLine.startswith("%"):
|
elif aLine.startswith("%"):
|
||||||
if nTitle > 0:
|
if nTitle > 0:
|
||||||
@@ -463,33 +462,28 @@ class NWIndex():
|
|||||||
self._noteIndex[tHandle][sTitle]["updated"] = round(time())
|
self._noteIndex[tHandle][sTitle]["updated"] = round(time())
|
||||||
return
|
return
|
||||||
|
|
||||||
def _indexNoteRef(self, tHandle, aLine, nLine, nTitle):
|
def _indexKeyword(self, tHandle, aLine, nLine, nTitle, itemClass):
|
||||||
"""Validate and save the information about a reference to a tag
|
"""Validate and save the information about a reference to a tag
|
||||||
in another file.
|
in another file.
|
||||||
"""
|
"""
|
||||||
isValid, theBits, _ = self.scanThis(aLine)
|
isValid, theBits, _ = self.scanThis(aLine)
|
||||||
if not isValid or len(theBits) == 0:
|
if not isValid or len(theBits) < 2:
|
||||||
return False
|
logger.warning("Skipping keyword with %d value(s) in %s" % (len(theBits), tHandle))
|
||||||
|
return
|
||||||
|
|
||||||
|
if theBits[0] not in nwKeyWords.VALID_KEYS:
|
||||||
|
logger.warning("Skipping invalid keyword '%s' in %s" % (theBits[0], tHandle))
|
||||||
|
return
|
||||||
|
|
||||||
sTitle = "T%06d" % nTitle
|
sTitle = "T%06d" % nTitle
|
||||||
if sTitle in self._refIndex[tHandle] and theBits[0] != nwKeyWords.TAG_KEY:
|
if theBits[0] == nwKeyWords.TAG_KEY:
|
||||||
|
self._tagIndex[theBits[1]] = [nLine, tHandle, itemClass.name, sTitle]
|
||||||
|
|
||||||
|
elif sTitle in self._refIndex[tHandle]:
|
||||||
for aVal in theBits[1:]:
|
for aVal in theBits[1:]:
|
||||||
self._refIndex[tHandle][sTitle]["tags"].append([nLine, theBits[0], aVal])
|
self._refIndex[tHandle][sTitle]["tags"].append([nLine, theBits[0], aVal])
|
||||||
|
|
||||||
return True
|
return
|
||||||
|
|
||||||
def _indexTag(self, tHandle, aLine, nLine, nTitle, itemClass):
|
|
||||||
"""Validate and save the information from a tag.
|
|
||||||
"""
|
|
||||||
isValid, theBits, thePos = self.scanThis(aLine)
|
|
||||||
if not isValid or len(theBits) != 2:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if theBits[0] == nwKeyWords.TAG_KEY:
|
|
||||||
sTitle = "T%06d" % nTitle
|
|
||||||
self._tagIndex[theBits[1]] = [nLine, tHandle, itemClass.name, sTitle]
|
|
||||||
|
|
||||||
return True
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Check @ Lines
|
# Check @ Lines
|
||||||
@@ -709,7 +703,7 @@ class NWIndex():
|
|||||||
for refTitle in self._refIndex[tHandle]:
|
for refTitle in self._refIndex[tHandle]:
|
||||||
for aTag in self._refIndex[tHandle][refTitle].get("tags", []):
|
for aTag in self._refIndex[tHandle][refTitle].get("tags", []):
|
||||||
if len(aTag) == 3 and (sTitle is None or sTitle == refTitle):
|
if len(aTag) == 3 and (sTitle is None or sTitle == refTitle):
|
||||||
if aTag[1] in theRefs: # Future-compatible. Check can be removed in 1.2.
|
if aTag[1] in theRefs:
|
||||||
theRefs[aTag[1]].append(aTag[2])
|
theRefs[aTag[1]].append(aTag[2])
|
||||||
|
|
||||||
return theRefs
|
return theRefs
|
||||||
|
|||||||
@@ -198,14 +198,28 @@ def testCoreIndex_CheckThese(nwMinimal, dummyGUI):
|
|||||||
|
|
||||||
assert theIndex.scanText(cHandle, (
|
assert theIndex.scanText(cHandle, (
|
||||||
"# Jane Smith\n"
|
"# Jane Smith\n"
|
||||||
"@tag: Jane"
|
"@tag: Jane\n"
|
||||||
|
"@tag:\n"
|
||||||
|
"@:\n"
|
||||||
))
|
))
|
||||||
assert theIndex.scanText(nHandle, (
|
assert theIndex.scanText(nHandle, (
|
||||||
"# Hello World!\n"
|
"# Hello World!\n"
|
||||||
"@pov: Jane"
|
"@pov: Jane\n"
|
||||||
|
"@invalid: John\n" # Checks for issue #688
|
||||||
))
|
))
|
||||||
assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]}
|
assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]}
|
||||||
assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!"
|
assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!"
|
||||||
|
assert theIndex.getReferences(nHandle, "T000001") == {
|
||||||
|
"@char": [],
|
||||||
|
"@custom": [],
|
||||||
|
"@entity": [],
|
||||||
|
"@focus": [],
|
||||||
|
"@location": [],
|
||||||
|
"@object": [],
|
||||||
|
"@plot": [],
|
||||||
|
"@pov": ["Jane"],
|
||||||
|
"@time": []
|
||||||
|
}
|
||||||
|
|
||||||
assert theIndex.novelChangedSince(0)
|
assert theIndex.novelChangedSince(0)
|
||||||
assert theIndex.notesChangedSince(0)
|
assert theIndex.notesChangedSince(0)
|
||||||
@@ -281,7 +295,7 @@ def testCoreIndex_ScanText(nwMinimal, dummyGUI):
|
|||||||
"This is a story about Jane Smith.\n\n"
|
"This is a story about Jane Smith.\n\n"
|
||||||
"Well, not really.\n"
|
"Well, not really.\n"
|
||||||
))
|
))
|
||||||
assert str(theIndex._tagIndex) == "{'Jane': [2, '%s', 'CHARACTER', 'T000001']}" % cHandle
|
assert theIndex._tagIndex == {"Jane": [2, cHandle, "CHARACTER", "T000001"]}
|
||||||
assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!"
|
assert theIndex.getNovelData(nHandle, "T000001")["title"] == "Hello World!"
|
||||||
|
|
||||||
# Check that title sections are indexed properly
|
# Check that title sections are indexed properly
|
||||||
|
|||||||
Reference in New Issue
Block a user