From 7687259381f0035acc8dd1a7b9aa833346d2c375 Mon Sep 17 00:00:00 2001 From: "Veronica K. B. Olsen" <1619840+vkbo@users.noreply.github.com> Date: Wed, 31 Mar 2021 18:53:54 +0200 Subject: [PATCH] Non-existing project dictionary file shouldn't prevent the vraiable from being set --- nw/core/spellcheck.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/nw/core/spellcheck.py b/nw/core/spellcheck.py index 9d22afcd..736d1fb4 100644 --- a/nw/core/spellcheck.py +++ b/nw/core/spellcheck.py @@ -108,26 +108,27 @@ class NWSpellCheck(): 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