Added class methods to get the default dictonaries path and the global user dictionaries path to the spell checker. 5_2_x

Fri, 09 Nov 2012 16:36:30 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 09 Nov 2012 16:36:30 +0100
branch
5_2_x
changeset 2202
fe0711184396
parent 2201
2cb2e3bb4f3f
child 2203
e12807485d16

Added class methods to get the default dictonaries path and the global user dictionaries path to the spell checker.

QScintilla/SpellChecker.py file | annotate | diff | comparison | revisions
diff -r 2cb2e3bb4f3f -r fe0711184396 QScintilla/SpellChecker.py
--- a/QScintilla/SpellChecker.py	Fri Nov 09 16:35:27 2012 +0100
+++ b/QScintilla/SpellChecker.py	Fri Nov 09 16:36:30 2012 +0100
@@ -84,6 +84,41 @@
         return False
     
     @classmethod
+    def getDefaultPath(cls, isException=False):
+        """
+        Class method to get the default path names of the user dictionaries.
+        
+        @param isException flag indicating to return the name of the default 
+            exception dictionary (boolean)
+        @return file name of the default user dictionary or the default user
+            exception dictionary (string)
+        """
+        if isException:
+            return os.path.join(Utilities.getConfigDir(), "spelling", "pel.dic")
+        else:
+            return os.path.join(Utilities.getConfigDir(), "spelling", "pwl.dic")
+    
+    @classmethod
+    def getUserDictionaryPath(cls, isException):
+        """
+        Class method to get the path name of a user dictionary file.
+        
+        @param isException flag indicating to return the name of the user
+            exception dictionary (boolean)
+        @return file name of the user dictionary or the user exception
+            dictionary (string)
+        """
+        if isException:
+            dicFile = Preferences.getEditor("SpellCheckingPersonalExcludeList")
+            if not dicFile:
+                dicFile = SpellChecker.getDefaultPath(False)
+        else:
+            dicFile = Preferences.getEditor("SpellCheckingPersonalWordList")
+            if not dicFile:
+                dicFile = SpellChecker.getDefaultPath()
+        return dicFile
+    
+    @classmethod
     def _getDict(cls, lang, pwl="", pel=""):
         """
         Protected classmethod to get a new dictionary.
@@ -95,17 +130,13 @@
         @return reference to the dictionary (enchant.Dict)
         """
         if not pwl:
-            pwl = Preferences.getEditor("SpellCheckingPersonalWordList")
-            if not pwl:
-                pwl = os.path.join(Utilities.getConfigDir(), "spelling", "pwl.dic")
+            pwl = SpellChecker.getUserDictionaryPath()
             d = os.path.dirname(pwl)
             if not os.path.exists(d):
                 os.makedirs(d)
         
         if not pel:
-            pel = Preferences.getEditor("SpellCheckingPersonalExcludeList")
-            if not pel:
-                pel = os.path.join(Utilities.getConfigDir(), "spelling", "pel.dic")
+            pel = SpellChecker.getUserDictionaryPath(False)
             d = os.path.dirname(pel)
             if not os.path.exists(d):
                 os.makedirs(d)

eric ide

mercurial