Plugins/CheckerPlugins/Pep8/Pep8Dialog.py

changeset 2915
9da653363d07
parent 2914
6b30a602e404
child 2916
a8628dfdfe04
diff -r 6b30a602e404 -r 9da653363d07 Plugins/CheckerPlugins/Pep8/Pep8Dialog.py
--- a/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py	Sat Sep 14 18:09:53 2013 +0200
+++ b/Plugins/CheckerPlugins/Pep8/Pep8Dialog.py	Sun Sep 15 19:55:39 2013 +0200
@@ -28,6 +28,8 @@
 # register the name checker
 pep8.register_check(Pep8NamingChecker, Pep8NamingChecker.Codes)
 
+from .Pep257Checker import Pep257Checker
+
 
 class Pep8Report(pep8.BaseReport):
     """
@@ -152,6 +154,8 @@
             itm.setIcon(1, UI.PixmapCache.getIcon("warning.png"))
         elif code.startswith("N"):
             itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png"))
+        elif code.startswith("D"):
+            itm.setIcon(1, UI.PixmapCache.getIcon("docstringError.png"))
         else:
             itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png"))
         if fixed:
@@ -406,6 +410,7 @@
                             hang_closing=hangClosing,
                         )
                         report.errors.sort(key=lambda a: a[1])
+                        # TODO: add PEP-257 check for Py2
                     else:
                         if includeMessages:
                             select = [s.strip() for s in includeMessages.split(',')
@@ -417,6 +422,8 @@
                                       if i.strip()]
                         else:
                             ignore = []
+                        
+                        # check PEP-8
                         styleGuide = pep8.StyleGuide(
                             reporter=Pep8Report,
                             repeat=repeatMessages,
@@ -427,8 +434,15 @@
                         )
                         report = styleGuide.check_files([file])
                         report.errors.sort(key=lambda a: a[1])
+                        
+                        # check PEP-257
+                        pep257Checker = Pep257Checker(
+                            source, file, select, ignore, [], repeatMessages)
+                        pep257Checker.run()
+                        pep257Checker.errors.sort(key=lambda a: a[1])
+                    
                     deferredFixes = {}
-                    for error in report.errors:
+                    for error in report.errors + pep257Checker.errors:
                         fname, lineno, position, text = error
                         if lineno > len(source):
                             lineno = len(source)
@@ -464,7 +478,10 @@
                             else:
                                 self.__modifyFixedResultItem(itm, "", False)
                         fixer.saveFile(encoding)
-                    self.__updateStatistics(report.counters, fixer)
+                    stats = {}
+                    stats.update(report.counters)
+                    stats.update(pep257Checker.counters)
+                    self.__updateStatistics(stats, fixer)
                     progress += 1
             finally:
                 # reenable updates of the list

eric ide

mercurial