Plugins/CheckerPlugins/Pep8/Pep8Checker.py

changeset 847
cc18fbcde9fc
parent 843
522c8befcf49
child 945
8cd4d08fa9f6
child 1178
2d22b5ce9384
equal deleted inserted replaced
846:869c200be26e 847:cc18fbcde9fc
58 pep8.options.messages = {} 58 pep8.options.messages = {}
59 59
60 pep8.Checker.__init__(self, filename, lines) 60 pep8.Checker.__init__(self, filename, lines)
61 61
62 self.messages = [] 62 self.messages = []
63 self.statistics = {}
63 64
64 def __ignore_code(self, code): 65 def __ignore_code(self, code):
65 """ 66 """
66 Private method to check, if the message for the given code should 67 Private method to check, if the message for the given code should
67 be ignored. 68 be ignored.
101 """ 102 """
102 if self.__ignore_code(code): 103 if self.__ignore_code(code):
103 return 104 return
104 105
105 text = pep8.getMessage(code, *args) 106 text = pep8.getMessage(code, *args)
106 if code in pep8.options.counters: 107 if code in self.statistics:
107 pep8.options.counters[code] += 1 108 self.statistics[code] += 1
108 else: 109 else:
109 pep8.options.counters[code] = 1 110 self.statistics[code] = 1
110 pep8.options.messages[code] = text[5:]
111 self.file_errors += 1 111 self.file_errors += 1
112 if pep8.options.counters[code] == 1 or pep8.options.repeat: 112 if self.statistics[code] == 1 or pep8.options.repeat:
113 self.messages.append( 113 self.messages.append(
114 (self.filename, self.line_offset + line_number, 114 (self.filename, self.line_offset + line_number,
115 offset + 1, text) 115 offset + 1, text)
116 ) 116 )
117 117
131 (comma separated string) 131 (comma separated string)
132 @keyparam ignore list of message IDs to ignore 132 @keyparam ignore list of message IDs to ignore
133 (comma separated string) 133 (comma separated string)
134 """ 134 """
135 self.messages = [] 135 self.messages = []
136 self.statistics = {}
136 137
137 interpreter = Preferences.getDebugger("PythonInterpreter") 138 interpreter = Preferences.getDebugger("PythonInterpreter")
138 if interpreter == "" or not Utilities.isExecutable(interpreter): 139 if interpreter == "" or not Utilities.isExecutable(interpreter):
139 self.messages.append(filename, "1", "1", 140 self.messages.append(filename, "1", "1",
140 self.trUtf8("Python2 interpreter not configured.")) 141 self.trUtf8("Python2 interpreter not configured."))
171 if output[0] == "NO_PEP8": 172 if output[0] == "NO_PEP8":
172 return 173 return
173 174
174 index = 0 175 index = 0
175 while index < len(output): 176 while index < len(output):
177 if output[index] == "PEP8_STATISTICS":
178 index += 1
179 break
180
176 fname = output[index + 1] 181 fname = output[index + 1]
177 lineno = int(output[index + 2]) 182 lineno = int(output[index + 2])
178 position = int(output[index + 3]) 183 position = int(output[index + 3])
179 code = output[index + 4] 184 code = output[index + 4]
180 arglen = int(output[index + 5]) 185 arglen = int(output[index + 5])
185 argindex += 1 190 argindex += 1
186 index += 6 + arglen 191 index += 6 + arglen
187 192
188 text = pep8.getMessage(code, *args) 193 text = pep8.getMessage(code, *args)
189 self.messages.append((fname, lineno, position, text)) 194 self.messages.append((fname, lineno, position, text))
195 while index < len(output):
196 code, countStr = output[index].split(None, 1)
197 self.statistics[code] = int(countStr)
198 index += 1
190 else: 199 else:
191 self.messages.append(filename, "1", "1", 200 self.messages.append(filename, "1", "1",
192 self.trUtf8("Python2 interpreter did not finish within 15s.")) 201 self.trUtf8("Python2 interpreter did not finish within 15s."))

eric ide

mercurial