QScintilla/SpellChecker.py

branch
Py2 comp.
changeset 3057
10516539f238
parent 2525
8b507a9a2d40
parent 3011
18292228c724
child 3145
a9de05d4a22f
--- a/QScintilla/SpellChecker.py	Tue Oct 15 22:03:54 2013 +0200
+++ b/QScintilla/SpellChecker.py	Fri Oct 18 23:00:41 2013 +0200
@@ -32,15 +32,18 @@
     _spelling_lang = None
     _spelling_dict = None
     
-    def __init__(self, editor, indicator, defaultLanguage=None, checkRegion=None):
+    def __init__(self, editor, indicator, defaultLanguage=None,
+                 checkRegion=None):
         """
         Constructor
         
         @param editor reference to the editor object (QScintilla.Editor)
         @param indicator spell checking indicator
-        @keyparam defaultLanguage the language to be used as the default (string).
-            The string should be in language locale format (e.g. en_US, de).
-        @keyparam checkRegion reference to a function to check for a valid region
+        @keyparam defaultLanguage the language to be used as the default
+            (string). The string should be in language locale format
+            (e.g. en_US, de).
+        @keyparam checkRegion reference to a function to check for a valid
+            region
         """
         super(SpellChecker, self).__init__(editor)
         
@@ -96,9 +99,11 @@
             exception dictionary (string)
         """
         if isException:
-            return os.path.join(Utilities.getConfigDir(), "spelling", "pel.dic")
+            return os.path.join(
+                Utilities.getConfigDir(), "spelling", "pel.dic")
         else:
-            return os.path.join(Utilities.getConfigDir(), "spelling", "pwl.dic")
+            return os.path.join(
+                Utilities.getConfigDir(), "spelling", "pwl.dic")
     
     @classmethod
     def getUserDictionaryPath(cls, isException=False):
@@ -193,7 +198,8 @@
     
     def __getNextWord(self, pos, endPosition):
         """
-        Private method to get the next word in the text after the given position.
+        Private method to get the next word in the text after the given
+        position.
         
         @param pos position to start word extraction (integer)
         @param endPosition position to stop word extraction (integer)
@@ -242,7 +248,8 @@
         Public method to get information about the last error found.
         
         @return tuple of last faulty word (string), starting position of the
-            faulty word (integer) and ending position of the faulty word (integer)
+            faulty word (integer) and ending position of the faulty word
+            (integer)
         """
         return (self.word, self.wordStart, self.wordEnd)
     
@@ -261,7 +268,8 @@
         if spell is None:
             return False
         
-        self.editor.clearIndicatorRange(self.indicator, startPos, endPos - startPos)
+        self.editor.clearIndicatorRange(
+            self.indicator, startPos, endPos - startPos)
         
         self.pos = startPos
         self.endPos = endPos
@@ -296,7 +304,8 @@
             return
         
         linesChunk = Preferences.getEditor("AutoSpellCheckChunkSize")
-        self.checkLines(self.lastCheckedLine, self.lastCheckedLine + linesChunk)
+        self.checkLines(self.lastCheckedLine,
+                        self.lastCheckedLine + linesChunk)
         self.lastCheckedLine = self.lastCheckedLine + linesChunk + 1
         if self.lastCheckedLine >= self.editor.lines():
             self.lastCheckedLine = -1
@@ -323,7 +332,8 @@
             pos1 = -1
             if not self.editor.charAt(pos).isalnum():
                 line, index = self.editor.lineIndexFromPosition(pos)
-                self.editor.clearIndicator(self.indicator, line, index, line, index + 1)
+                self.editor.clearIndicator(
+                    self.indicator, line, index, line, index + 1)
                 pos1 = self.editor.positionAfter(pos)
                 pos0 = self.editor.positionBefore(pos)
             
@@ -335,13 +345,15 @@
                         ok = spell.check(word)
                     else:
                         ok = True
-                    start, end = \
-                        self.editor.getWordBoundaries(line, index, useWordChars=False)
+                    start, end = self.editor.getWordBoundaries(
+                        line, index, useWordChars=False)
                     if ok:
-                        self.editor.clearIndicator(self.indicator, line, start, line, end)
+                        self.editor.clearIndicator(
+                            self.indicator, line, start, line, end)
                     else:
                         # spell check indicated an error
-                        self.editor.setIndicator(self.indicator, line, start, line, end)
+                        self.editor.setIndicator(
+                            self.indicator, line, start, line, end)
     
     def checkLines(self, firstLine, lastLine):
         """
@@ -360,7 +372,7 @@
     
     def checkDocument(self):
         """
-        Public method to check the complete document
+        Public method to check the complete document.
         """
         self.__checkDocumentPart(0, self.editor.length())
     
@@ -405,7 +417,8 @@
         """
         Public method to clear all spelling markers.
         """
-        self.editor.clearIndicatorRange(self.indicator, 0, self.editor.length())
+        self.editor.clearIndicatorRange(
+            self.indicator, 0, self.editor.length())
     
     def getSuggestions(self, word):
         """
@@ -491,6 +504,8 @@
     def __iter__(self):
         """
         Private method to create an iterator.
+        
+        @return self
         """
         return self
     
@@ -499,11 +514,13 @@
         Public method to advance to the next error.
         
         @return self
+        @exception StopIteration raised to indicate the end of the iteration
         """
         spell = self._spelling_dict
         if spell:
             while self.pos < self.endPos and self.pos >= 0:
-                word, wordStart, wordEnd = self.__getNextWord(self.pos, self.endPos)
+                word, wordStart, wordEnd = \
+                    self.__getNextWord(self.pos, self.endPos)
                 self.pos = wordEnd
                 if (wordEnd - wordStart) >= self.minimumWordSize and \
                    self.__checkRegion(wordStart):

eric ide

mercurial