Changed the syntac checker dialog and the tabnanny dialog to use the new eflag: marker.

Fri, 31 Dec 2010 17:55:36 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 31 Dec 2010 17:55:36 +0100
changeset 793
cd183f89874b
parent 791
9ec2ac20e54e
child 794
e338e1e8f3ca

Changed the syntac checker dialog and the tabnanny dialog to use the new eflag: marker.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.html file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/Tabnanny/Tabnanny.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py file | annotate | diff | comparison | revisions
eric5.e4p file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Fri Dec 31 15:49:50 2010 +0100
+++ b/APIs/Python3/eric5.api	Fri Dec 31 17:55:36 2010 +0100
@@ -2642,7 +2642,7 @@
 eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.Whitespace.not_equal_witness?4(other)
 eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.Whitespace.not_less_witness?4(other)
 eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.Whitespace?1(ws)
-eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.check?4(file)
+eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.check?4(file, text = "")
 eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.format_witnesses?4(w)
 eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.process_tokens?4(tokens)
 eric5.Plugins.CheckerPlugins.Tabnanny.TabnannyDialog.TabnannyDialog.on_buttonBox_clicked?4(button)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Source/eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.html	Fri Dec 31 15:49:50 2010 +0100
+++ b/Documentation/Source/eric5.Plugins.CheckerPlugins.Tabnanny.Tabnanny.html	Fri Dec 31 17:55:36 2010 +0100
@@ -292,13 +292,16 @@
 <hr /><hr />
 <a NAME="check" ID="check"></a>
 <h2>check</h2>
-<b>check</b>(<i>file</i>)
+<b>check</b>(<i>file, text = ""</i>)
 <p>
     Private function to check one Python source file for whitespace related problems.
 </p><dl>
 <dt><i>file</i></dt>
 <dd>
 source filename (string)
+</dd><dt><i>text</i></dt>
+<dd>
+source text (string)
 </dd>
 </dl><dl>
 <dt>Returns:</dt>
--- a/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Fri Dec 31 15:49:50 2010 +0100
+++ b/Plugins/CheckerPlugins/SyntaxChecker/SyntaxCheckerDialog.py	Fri Dec 31 17:55:36 2010 +0100
@@ -151,6 +151,10 @@
             # now go through all the files
             progress = 0
             for file in files:
+                self.checkProgress.setValue(progress)
+                QApplication.processEvents()
+                self.__resort()
+                
                 if self.cancelled:
                     return
                 
@@ -163,8 +167,18 @@
                         source = Utilities.readEncodedFile(file)[0]
                         # convert eols
                         source = Utilities.convertLineEnds(source, "\n")
-                    except (UnicodeDecodeError, IOError):
-                        continue    # just ignore it
+                    except (UnicodeError, IOError) as msg:
+                        self.noResults = False
+                        self.__createResultItem(file, "1", 
+                            "Error: {0}".format(str(msg)).rstrip()[1:-1])
+                        progress += 1
+                        continue
+                
+                flags = Utilities.extractFlags(source)
+                if "FileType" in flags and flags["FileType"] != "Python3":
+                    # skip non Python 3 files
+                    progress += 1
+                    continue
                 
                 nok, fname, line, code, error = Utilities.compile(file, source)
                 if nok:
@@ -180,10 +194,10 @@
                                 if ignoreStarImportWarnings and \
                                    isinstance(warning, ImportStarUsed):
                                     continue
-                                self.noResults = False
                                 fname, lineno, message = warning.getMessageData()
                                 if not sourceLines[lineno - 1].strip()\
                                    .endswith("__IGNORE_WARNING__"):
+                                    self.noResults = False
                                     self.__createResultItem(fname, lineno, message, "", 
                                                             isWarning = True)
                         except SyntaxError as err:
@@ -193,9 +207,9 @@
                                 msg = err.msg
                             self.__createResultItem(err.filename, err.lineno, msg, "")
                 progress += 1
-                self.checkProgress.setValue(progress)
-                QApplication.processEvents()
-                self.__resort()
+            self.checkProgress.setValue(progress)
+            QApplication.processEvents()
+            self.__resort()
         else:
             self.checkProgress.setMaximum(1)
             self.checkProgress.setValue(1)
@@ -252,6 +266,8 @@
                     [f for f in fileList if not fnmatch.fnmatch(f, filter.strip())]
         
         self.resultList.clear()
+        self.noResults = True
+        self.cancelled = False
         self.start(fileList)
         
     def on_resultList_itemActivated(self, itm, col):
--- a/Plugins/CheckerPlugins/Tabnanny/Tabnanny.py	Fri Dec 31 15:49:50 2010 +0100
+++ b/Plugins/CheckerPlugins/Tabnanny/Tabnanny.py	Fri Dec 31 17:55:36 2010 +0100
@@ -40,7 +40,6 @@
 
 __version__ = "6_eric"
 
-import os
 import tokenize
 import io
 
@@ -90,11 +89,12 @@
         """
         return self.line
 
-def check(file):
+def check(file, text = ""):
     """
     Private function to check one Python source file for whitespace related problems.
     
     @param file source filename (string)
+    @param text source text (string)
     @return A tuple indicating status (True = an error was found), the
         filename, the linenumber and the error message
         (boolean, string, string, string). The values are only
@@ -103,14 +103,15 @@
     global indents, check_equal
     indents = [Whitespace("")]
     check_equal = 0
-
-    try:
-        text = Utilities.readEncodedFile(file)[0]
-    except (UnicodeError, IOError) as msg:
-        return (True, file, "1", "Error: {0}".format(str(msg)))
-        
-    # convert eols
-    text = Utilities.convertLineEnds(text, os.linesep)
+    
+    if not text:
+        try:
+            text = Utilities.readEncodedFile(file)[0]
+        except (UnicodeError, IOError) as msg:
+            return (True, file, "1", "Error: {0}".format(str(msg)))
+            
+        # convert eols
+        text = Utilities.convertLineEnds(text, "\n")
     
     source = io.StringIO(text)
     try:
--- a/Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py	Fri Dec 31 15:49:50 2010 +0100
+++ b/Plugins/CheckerPlugins/Tabnanny/TabnannyDialog.py	Fri Dec 31 17:55:36 2010 +0100
@@ -119,17 +119,39 @@
             # now go through all the files
             progress = 0
             for file in files:
+                self.checkProgress.setValue(progress)
+                QApplication.processEvents()
+                self.__resort()
+                
                 if self.cancelled:
                     return
                 
-                nok, fname, line, error = Tabnanny.check(file)
+                try:
+                    source = Utilities.readEncodedFile(file)[0]
+                    # convert eols
+                    source = Utilities.convertLineEnds(source, "\n")
+                except (UnicodeError, IOError) as msg:
+                    self.noResults = False
+                    self.__createResultItem(file, "1", 
+                        "Error: {0}".format(str(msg)).rstrip()[1:-1])
+                    progress += 1
+                    continue
+                
+                flags = Utilities.extractFlags(source)
+                if "FileType" in flags and flags["FileType"] != "Python3":
+                    # skip non Python 3 files
+                    progress += 1
+                    continue
+                
+                nok, fname, line, error = Tabnanny.check(file, source)
                 if nok:
                     self.noResults = False
                     self.__createResultItem(fname, line, error.rstrip()[1:-1])
                 progress += 1
-                self.checkProgress.setValue(progress)
-                QApplication.processEvents()
-                self.__resort()
+                
+            self.checkProgress.setValue(progress)
+            QApplication.processEvents()
+            self.__resort()
         else:
             self.checkProgress.setMaximum(1)
             self.checkProgress.setValue(1)
@@ -180,6 +202,8 @@
                     [f for f in fileList if not fnmatch.fnmatch(f, filter.strip())]
         
         self.resultList.clear()
+        self.noResults = True
+        self.cancelled = False
         self.start(fileList)
         
     def on_resultList_itemActivated(self, itm, col):
--- a/eric5.e4p	Fri Dec 31 15:49:50 2010 +0100
+++ b/eric5.e4p	Fri Dec 31 17:55:36 2010 +0100
@@ -1499,7 +1499,7 @@
               <string>ExcludeFiles</string>
             </key>
             <value>
-              <string>*/DebugClients/Python/*, */coverage/*, */ThirdParty/*</string>
+              <string>*/coverage/*, */ThirdParty/*</string>
             </value>
           </dict>
         </value>
@@ -1512,7 +1512,7 @@
               <string>ExcludeFiles</string>
             </key>
             <value>
-              <string>*/DebugClients/Python/*, */coverage/*, */ThirdParty/*</string>
+              <string>*/coverage/*, */ThirdParty/*</string>
             </value>
           </dict>
         </value>

eric ide

mercurial