Plugins/CheckerPlugins/Pep8/Pep8Dialog.py

changeset 2894
8e4264045fc9
parent 2891
6843b7d23279
child 2895
4a44d92757f9
equal deleted inserted replaced
2893:150de635fa29 2894:8e4264045fc9
21 from .Ui_Pep8Dialog import Ui_Pep8Dialog 21 from .Ui_Pep8Dialog import Ui_Pep8Dialog
22 22
23 import UI.PixmapCache 23 import UI.PixmapCache
24 import Preferences 24 import Preferences
25 import Utilities 25 import Utilities
26
27 from .Pep8NamingChecker import Pep8NamingChecker
26 28
27 29
28 class Pep8Report(pep8.BaseReport): 30 class Pep8Report(pep8.BaseReport):
29 """ 31 """
30 Class implementing a special report to be used with our dialog. 32 Class implementing a special report to be used with our dialog.
50 @param check reference to the checker function (function) 52 @param check reference to the checker function (function)
51 @param args arguments for the message (list) 53 @param args arguments for the message (list)
52 """ 54 """
53 code = super().error_args(line_number, offset, code, check, *args) 55 code = super().error_args(line_number, offset, code, check, *args)
54 if code and (self.counters[code] == 1 or self.__repeat): 56 if code and (self.counters[code] == 1 or self.__repeat):
55 text = pep8.getMessage(code, *args) 57 if code in Pep8NamingChecker.Codes:
58 text = Pep8NamingChecker.getMessage(code, *args)
59 else:
60 text = pep8.getMessage(code, *args)
56 self.errors.append( 61 self.errors.append(
57 (self.filename, line_number, offset, text) 62 (self.filename, line_number, offset, text)
58 ) 63 )
59 return code 64 return code
60 65
104 self.__forProject = False 109 self.__forProject = False
105 self.__data = {} 110 self.__data = {}
106 self.__statistics = {} 111 self.__statistics = {}
107 112
108 self.on_loadDefaultButton_clicked() 113 self.on_loadDefaultButton_clicked()
114
115 # register the name checker
116 pep8.register_check(Pep8NamingChecker, Pep8NamingChecker.Codes)
109 117
110 def __resort(self): 118 def __resort(self):
111 """ 119 """
112 Private method to resort the tree. 120 Private method to resort the tree.
113 """ 121 """
141 code, message = message.split(None, 1) 149 code, message = message.split(None, 1)
142 itm = QTreeWidgetItem(self.__lastFileItem, 150 itm = QTreeWidgetItem(self.__lastFileItem,
143 ["{0:6}".format(line), code, message]) 151 ["{0:6}".format(line), code, message])
144 if code.startswith("W"): 152 if code.startswith("W"):
145 itm.setIcon(1, UI.PixmapCache.getIcon("warning.png")) 153 itm.setIcon(1, UI.PixmapCache.getIcon("warning.png"))
154 elif code.startswith("N"):
155 itm.setIcon(1, UI.PixmapCache.getIcon("namingError.png"))
146 else: 156 else:
147 itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png")) 157 itm.setIcon(1, UI.PixmapCache.getIcon("syntaxError.png"))
148 if fixed: 158 if fixed:
149 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png")) 159 itm.setIcon(0, UI.PixmapCache.getIcon("issueFixed.png"))
150 elif code in Pep8FixableIssues and not autofixing: 160 elif code in Pep8FixableIssues and not autofixing:

eric ide

mercurial