Merge branch 'dev' into projsettings_update

This commit is contained in:
Veronica K. B. Olsen
2021-02-27 17:02:23 +01:00
17 changed files with 5282 additions and 418 deletions
+14 -28
View File
@@ -318,8 +318,7 @@ class NWIndex():
nTitle = nLine
elif aLine.startswith("@"):
self._indexNoteRef(tHandle, aLine, nLine, nTitle)
self._indexTag(tHandle, aLine, nLine, nTitle, itemClass)
self._indexKeyword(tHandle, aLine, nLine, nTitle, itemClass)
elif aLine.startswith("%"):
if nTitle > 0:
@@ -460,41 +459,28 @@ class NWIndex():
self._noteIndex[tHandle][sTitle]["updated"] = round(time())
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
in another file.
"""
isValid, theBits, _ = self.scanThis(aLine)
if not isValid or len(theBits) == 0:
return False
sTitle = "T%06d" % nTitle
if sTitle not in self._refIndex[tHandle]:
return False
if theBits[0] == nwKeyWords.TAG_KEY:
return False
if not isValid or len(theBits) < 2:
logger.warning("Skipping keyword with %d value(s) in %s" % (len(theBits), tHandle))
return
if theBits[0] not in nwKeyWords.VALID_KEYS:
return False
for aVal in theBits[1:]:
self._refIndex[tHandle][sTitle]["tags"].append([nLine, theBits[0], aVal])
return True
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
logger.warning("Skipping invalid keyword '%s' in %s" % (theBits[0], tHandle))
return
sTitle = "T%06d" % nTitle
if theBits[0] == nwKeyWords.TAG_KEY:
sTitle = "T%06d" % nTitle
self._tagIndex[theBits[1]] = [nLine, tHandle, itemClass.name, sTitle]
return True
elif sTitle in self._refIndex[tHandle]:
for aVal in theBits[1:]:
self._refIndex[tHandle][sTitle]["tags"].append([nLine, theBits[0], aVal])
return
##
# Check @ Lines
@@ -714,7 +700,7 @@ 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):
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])
return theRefs
+2 -2
View File
@@ -988,7 +988,7 @@ class NWProject():
if not os.path.isdir(self.mainConf.backupPath):
self.theParent.makeAlert(
self.tr(
"You must set a valid backup path in preferences to use "
"You must set a valid backup path in Preferences to use "
"the automatic project backup feature."
), nwAlert.WARN
)
@@ -997,7 +997,7 @@ class NWProject():
if self.projName == "":
self.theParent.makeAlert(
self.tr(
"You must set a valid project name in project settings to "
"You must set a valid project name in Project Settings to "
"use the automatic project backup feature."
), nwAlert.WARN
)