Skip to content

Commit

Permalink
Merge pull request #734 from vkbo/issue733_project_wordlist
Browse files Browse the repository at this point in the history
Fix failed initial project dictionary
  • Loading branch information
vkbo authored Mar 31, 2021
2 parents 1e64a3f + 7687259 commit 641ff44
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions nw/core/spellcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,26 +108,27 @@ def _readProjectDictionary(self, projectDict):
lookup lists.
"""
self.projDict = []
if projectDict is not None:
if not os.path.isfile(projectDict):
self.projectDict = None
return False
else:
self.projectDict = projectDict
self.projectDict = projectDict

try:
logger.debug("Loading project word list")
with open(projectDict, mode="r", encoding="utf-8") as wordsFile:
for theLine in wordsFile:
theLine = theLine.strip()
if len(theLine) > 0 and theLine not in self.projDict:
self.projDict.append(theLine)
logger.debug("Project word list contains %d words" % len(self.projDict))
if projectDict is None:
return False

except Exception:
logger.error("Failed to load project word list")
nw.logException()
return False
if not os.path.isfile(projectDict):
return False

try:
logger.debug("Loading project word list")
with open(projectDict, mode="r", encoding="utf-8") as wordsFile:
for theLine in wordsFile:
theLine = theLine.strip()
if len(theLine) > 0 and theLine not in self.projDict:
self.projDict.append(theLine)
logger.debug("Project word list contains %d words" % len(self.projDict))

except Exception:
logger.error("Failed to load project word list")
nw.logException()
return False

return True

Expand Down

0 comments on commit 641ff44

Please sign in to comment.