82 except NameError: |
82 except NameError: |
83 pass |
83 pass |
84 return False |
84 return False |
85 |
85 |
86 @classmethod |
86 @classmethod |
|
87 def getDefaultPath(cls, isException=False): |
|
88 """ |
|
89 Class method to get the default path names of the user dictionaries. |
|
90 |
|
91 @param isException flag indicating to return the name of the default |
|
92 exception dictionary (boolean) |
|
93 @return file name of the default user dictionary or the default user |
|
94 exception dictionary (string) |
|
95 """ |
|
96 if isException: |
|
97 return os.path.join(Utilities.getConfigDir(), "spelling", "pel.dic") |
|
98 else: |
|
99 return os.path.join(Utilities.getConfigDir(), "spelling", "pwl.dic") |
|
100 |
|
101 @classmethod |
|
102 def getUserDictionaryPath(cls, isException): |
|
103 """ |
|
104 Class method to get the path name of a user dictionary file. |
|
105 |
|
106 @param isException flag indicating to return the name of the user |
|
107 exception dictionary (boolean) |
|
108 @return file name of the user dictionary or the user exception |
|
109 dictionary (string) |
|
110 """ |
|
111 if isException: |
|
112 dicFile = Preferences.getEditor("SpellCheckingPersonalExcludeList") |
|
113 if not dicFile: |
|
114 dicFile = SpellChecker.getDefaultPath(False) |
|
115 else: |
|
116 dicFile = Preferences.getEditor("SpellCheckingPersonalWordList") |
|
117 if not dicFile: |
|
118 dicFile = SpellChecker.getDefaultPath() |
|
119 return dicFile |
|
120 |
|
121 @classmethod |
87 def _getDict(cls, lang, pwl="", pel=""): |
122 def _getDict(cls, lang, pwl="", pel=""): |
88 """ |
123 """ |
89 Protected classmethod to get a new dictionary. |
124 Protected classmethod to get a new dictionary. |
90 |
125 |
91 @param lang the language to be used as the default (string). |
126 @param lang the language to be used as the default (string). |
93 @keyparam pwl name of the personal/project word list (string) |
128 @keyparam pwl name of the personal/project word list (string) |
94 @keyparam pel name of the personal/project exclude list (string) |
129 @keyparam pel name of the personal/project exclude list (string) |
95 @return reference to the dictionary (enchant.Dict) |
130 @return reference to the dictionary (enchant.Dict) |
96 """ |
131 """ |
97 if not pwl: |
132 if not pwl: |
98 pwl = Preferences.getEditor("SpellCheckingPersonalWordList") |
133 pwl = SpellChecker.getUserDictionaryPath() |
99 if not pwl: |
|
100 pwl = os.path.join(Utilities.getConfigDir(), "spelling", "pwl.dic") |
|
101 d = os.path.dirname(pwl) |
134 d = os.path.dirname(pwl) |
102 if not os.path.exists(d): |
135 if not os.path.exists(d): |
103 os.makedirs(d) |
136 os.makedirs(d) |
104 |
137 |
105 if not pel: |
138 if not pel: |
106 pel = Preferences.getEditor("SpellCheckingPersonalExcludeList") |
139 pel = SpellChecker.getUserDictionaryPath(False) |
107 if not pel: |
|
108 pel = os.path.join(Utilities.getConfigDir(), "spelling", "pel.dic") |
|
109 d = os.path.dirname(pel) |
140 d = os.path.dirname(pel) |
110 if not os.path.exists(d): |
141 if not os.path.exists(d): |
111 os.makedirs(d) |
142 os.makedirs(d) |
112 |
143 |
113 try: |
144 try: |