Bugfix for statistics dialog of the code style checker. BgService

Thu, 27 Mar 2014 23:03:40 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Thu, 27 Mar 2014 23:03:40 +0100
branch
BgService
changeset 3443
7d919fd299f6
parent 3442
927186c0d409
child 3444
118cb489304d

Bugfix for statistics dialog of the code style checker.

Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py file | annotate | diff | comparison | revisions
Plugins/CheckerPlugins/CodeStyleChecker/translations.py file | annotate | diff | comparison | revisions
--- a/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py	Thu Mar 27 21:27:08 2014 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/CodeStyleStatisticsDialog.py	Thu Mar 27 23:03:40 2014 +0100
@@ -10,12 +10,10 @@
 
 from __future__ import unicode_literals
 
-from PyQt4.QtCore import Qt, QCoreApplication
+from PyQt4.QtCore import Qt
 from PyQt4.QtGui import QDialog, QTreeWidgetItem
 
-from . import pep8
-from .NamingStyleChecker import NamingStyleChecker
-from .DocStyleChecker import DocStyleChecker
+from .translations import _messages, _messages_sample_args
 
 from .Ui_CodeStyleStatisticsDialog import Ui_CodeStyleStatisticsDialog
 
@@ -27,7 +25,7 @@
     Class implementing a dialog showing statistical data for the last
     code style checker run.
     """
-    def __init__(self, statistics, parent=None):
+    def __init__ (self, statistics, parent=None):
         """
         Constructor
         
@@ -48,21 +46,13 @@
         totalIssues = 0
         
         for code in sorted(stats.keys()):
-            if code in pep8.pep8_messages_sample_args:
-                message = QCoreApplication.translate(
-                    "pep8", pep8.pep8_messages[code]).format(
-                    *pep8.pep8_messages_sample_args[code])
-            elif code in pep8.pep8_messages:
-                message = QCoreApplication.translate(
-                    "pep8", pep8.pep8_messages[code])
-            elif code in NamingStyleChecker.Messages:
-                message = QCoreApplication.translate(
-                    "NamingStyleChecker", NamingStyleChecker.Messages[code])
-            elif code in DocStyleChecker.Messages:
-                message = QCoreApplication.translate(
-                    "DocStyleChecker", DocStyleChecker.Messages[code])
-            else:
+            message = _messages.get(code)
+            if message is None:
                 continue
+            
+            if code in _messages_sample_args:
+                message = message.format(*_messages_sample_args[code])
+            
             self.__createItem(stats[code], code, message)
             totalIssues += stats[code]
         
--- a/Plugins/CheckerPlugins/CodeStyleChecker/translations.py	Thu Mar 27 21:27:08 2014 +0100
+++ b/Plugins/CheckerPlugins/CodeStyleChecker/translations.py	Thu Mar 27 23:03:40 2014 +0100
@@ -501,6 +501,23 @@
         "Could not save the file! Skipping it. Reason: {0}"),
 }
 
+_messages_sample_args = {
+    "E201": ["([{"],
+    "E202": ["}])"],
+    "E203": [",;:"],
+    "E211": ["(["],
+    "E231": [",;:"],
+    "E241": [",;:"],
+    "E242": [",;:"],
+    "E302": [1],
+    "E303": [3],
+    "E501": [85, 79],
+    "E711": ["None", "'if cond is None:'"],
+    "E712": ["True", "'if cond is True:' or 'if cond:'"],
+    "E901": ["SyntaxError", "Invalid Syntax"],
+    "D901": ["SyntaxError", "Invalid Syntax"],
+}
+
 
 def getTranslatedMessage(message):
     """

eric ide

mercurial