Cleaned up initialisation and config settings for spell checking
This commit is contained in:
+33
-9
@@ -41,7 +41,6 @@ class Config:
|
||||
self.appHandle = nw.__package__.lower()
|
||||
self.showGUI = True
|
||||
self.debugInfo = False
|
||||
self.spellTool = None
|
||||
|
||||
# Set Paths
|
||||
self.confPath = None
|
||||
@@ -94,7 +93,8 @@ class Config:
|
||||
self.fmtSingleQuotes = [nwUnicode.U_LSQUO,nwUnicode.U_RSQUO]
|
||||
self.fmtDoubleQuotes = [nwUnicode.U_LDQUO,nwUnicode.U_RDQUO]
|
||||
|
||||
self.spellLanguage = "en_GB"
|
||||
self.spellTool = None
|
||||
self.spellLanguage = None
|
||||
|
||||
## Backup
|
||||
self.backupPath = ""
|
||||
@@ -137,9 +137,9 @@ class Config:
|
||||
self.osDarwin = False
|
||||
self.osUnknown = False
|
||||
if self.osType.startswith("linux"):
|
||||
self.osLinux = True
|
||||
self.osLinux = True
|
||||
elif self.osType.startswith("darwin"):
|
||||
self.osDarwin = True
|
||||
self.osDarwin = True
|
||||
elif self.osType.startswith("win32"):
|
||||
self.osWindows = True
|
||||
elif self.osType.startswith("cygwin"):
|
||||
@@ -147,6 +147,9 @@ class Config:
|
||||
else:
|
||||
self.osUnknown = True
|
||||
|
||||
# Packages
|
||||
self.hasEnchant = False
|
||||
|
||||
return
|
||||
|
||||
##
|
||||
@@ -186,13 +189,16 @@ class Config:
|
||||
# If it exists, load it
|
||||
self.loadConfig()
|
||||
else:
|
||||
# If it does not exist, save a copy of the defaults
|
||||
# If it does not exist, save a copy of the default values
|
||||
self.saveConfig()
|
||||
|
||||
# Check the availability of optional packages
|
||||
self._checkOptionalPackages()
|
||||
|
||||
if self.spellTool is None:
|
||||
logger.warning("No spell check tool available")
|
||||
else:
|
||||
logger.debug("Using spell check tool '%s'" % self.spellTool)
|
||||
self.spellTool = "simple"
|
||||
if self.spellLanguage is None:
|
||||
self.spellLanguage = "en"
|
||||
|
||||
return True
|
||||
|
||||
@@ -288,8 +294,11 @@ class Config:
|
||||
self.fmtDoubleQuotes = self._parseLine(
|
||||
cnfParse, cnfSec, "fmtdoublequote", self.CNF_LIST, self.fmtDoubleQuotes
|
||||
)
|
||||
self.spellTool = self._parseLine(
|
||||
cnfParse, cnfSec, "spelltool", self.CNF_STR, self.spellTool
|
||||
)
|
||||
self.spellLanguage = self._parseLine(
|
||||
cnfParse, cnfSec, "spellcheck", self.CNF_STR, self.spellLanguage
|
||||
cnfParse, cnfSec, "spellcheck", self.CNF_STR, self.spellLanguage
|
||||
)
|
||||
self.showTabsNSpaces = self._parseLine(
|
||||
cnfParse, cnfSec, "showtabsnspaces", self.CNF_BOOL, self.showTabsNSpaces
|
||||
@@ -380,6 +389,7 @@ class Config:
|
||||
cnfParse.set(cnfSec,"repdots", str(self.doReplaceDots))
|
||||
cnfParse.set(cnfSec,"fmtsinglequote", self._packList(self.fmtSingleQuotes))
|
||||
cnfParse.set(cnfSec,"fmtdoublequote", self._packList(self.fmtDoubleQuotes))
|
||||
cnfParse.set(cnfSec,"spelltool", str(self.spellTool))
|
||||
cnfParse.set(cnfSec,"spellcheck", str(self.spellLanguage))
|
||||
cnfParse.set(cnfSec,"showtabsnspaces", str(self.showTabsNSpaces))
|
||||
cnfParse.set(cnfSec,"showlineendings", str(self.showLineEndings))
|
||||
@@ -520,4 +530,18 @@ class Config:
|
||||
return None
|
||||
return checkVal
|
||||
|
||||
def _checkOptionalPackages(self):
|
||||
"""Cheks if we have the optional packages used by some features.
|
||||
"""
|
||||
|
||||
try:
|
||||
import pyenchant
|
||||
self.hasEnchant = True
|
||||
logger.debug("Checking package pyenchant: Ok")
|
||||
except:
|
||||
self.hasEnchant = False
|
||||
logger.debug("Checking package pyenchant: Missing")
|
||||
|
||||
return
|
||||
|
||||
# End Class Config
|
||||
|
||||
Reference in New Issue
Block a user