Plugins/CheckerPlugins/Pep8/pep8.py

changeset 945
8cd4d08fa9f6
parent 850
8b9f09e7d5d9
child 1145
2a16484e65c2
equal deleted inserted replaced
944:1b59c4ba121e 945:8cd4d08fa9f6
159 # Helper functions for translated and formatted messages 159 # Helper functions for translated and formatted messages
160 ############################################################################## 160 ##############################################################################
161 161
162 162
163 pep8_messages = { 163 pep8_messages = {
164 "E101" : QT_TRANSLATE_NOOP("pep8", 164 "E101": QT_TRANSLATE_NOOP("pep8",
165 "indentation contains mixed spaces and tabs"), 165 "indentation contains mixed spaces and tabs"),
166 "E111" : QT_TRANSLATE_NOOP("pep8", 166 "E111": QT_TRANSLATE_NOOP("pep8",
167 "indentation is not a multiple of four"), 167 "indentation is not a multiple of four"),
168 "E112" : QT_TRANSLATE_NOOP("pep8", 168 "E112": QT_TRANSLATE_NOOP("pep8",
169 "expected an indented block"), 169 "expected an indented block"),
170 "E113" : QT_TRANSLATE_NOOP("pep8", 170 "E113": QT_TRANSLATE_NOOP("pep8",
171 "unexpected indentation"), 171 "unexpected indentation"),
172 "W191" : QT_TRANSLATE_NOOP("pep8", 172 "W191": QT_TRANSLATE_NOOP("pep8",
173 "indentation contains tabs"), 173 "indentation contains tabs"),
174 "E201" : QT_TRANSLATE_NOOP("pep8", 174 "E201": QT_TRANSLATE_NOOP("pep8",
175 "whitespace after '{0}'"), 175 "whitespace after '{0}'"),
176 "E202" : QT_TRANSLATE_NOOP("pep8", 176 "E202": QT_TRANSLATE_NOOP("pep8",
177 "whitespace before '{0}'"), 177 "whitespace before '{0}'"),
178 "E203" : QT_TRANSLATE_NOOP("pep8", 178 "E203": QT_TRANSLATE_NOOP("pep8",
179 "whitespace before '{0}'"), 179 "whitespace before '{0}'"),
180 "E211" : QT_TRANSLATE_NOOP("pep8", 180 "E211": QT_TRANSLATE_NOOP("pep8",
181 "whitespace before '{0}'"), 181 "whitespace before '{0}'"),
182 "E221" : QT_TRANSLATE_NOOP("pep8", 182 "E221": QT_TRANSLATE_NOOP("pep8",
183 "multiple spaces before operator"), 183 "multiple spaces before operator"),
184 "E222" : QT_TRANSLATE_NOOP("pep8", 184 "E222": QT_TRANSLATE_NOOP("pep8",
185 "multiple spaces after operator"), 185 "multiple spaces after operator"),
186 "E223" : QT_TRANSLATE_NOOP("pep8", 186 "E223": QT_TRANSLATE_NOOP("pep8",
187 "tab before operator"), 187 "tab before operator"),
188 "E224" : QT_TRANSLATE_NOOP("pep8", 188 "E224": QT_TRANSLATE_NOOP("pep8",
189 "tab after operator"), 189 "tab after operator"),
190 "E225" : QT_TRANSLATE_NOOP("pep8", 190 "E225": QT_TRANSLATE_NOOP("pep8",
191 "missing whitespace around operator"), 191 "missing whitespace around operator"),
192 "E231" : QT_TRANSLATE_NOOP("pep8", 192 "E231": QT_TRANSLATE_NOOP("pep8",
193 "missing whitespace after '{0}'"), 193 "missing whitespace after '{0}'"),
194 "E241" : QT_TRANSLATE_NOOP("pep8", 194 "E241": QT_TRANSLATE_NOOP("pep8",
195 "multiple spaces after '{0}'"), 195 "multiple spaces after '{0}'"),
196 "E242" : QT_TRANSLATE_NOOP("pep8", 196 "E242": QT_TRANSLATE_NOOP("pep8",
197 "tab after '{0}'"), 197 "tab after '{0}'"),
198 "E251" : QT_TRANSLATE_NOOP("pep8", 198 "E251": QT_TRANSLATE_NOOP("pep8",
199 "no spaces around keyword / parameter equals"), 199 "no spaces around keyword / parameter equals"),
200 "E261" : QT_TRANSLATE_NOOP("pep8", 200 "E261": QT_TRANSLATE_NOOP("pep8",
201 "at least two spaces before inline comment"), 201 "at least two spaces before inline comment"),
202 "E262" : QT_TRANSLATE_NOOP("pep8", 202 "E262": QT_TRANSLATE_NOOP("pep8",
203 "inline comment should start with '# '"), 203 "inline comment should start with '# '"),
204 "W291" : QT_TRANSLATE_NOOP("pep8", 204 "W291": QT_TRANSLATE_NOOP("pep8",
205 "trailing whitespace"), 205 "trailing whitespace"),
206 "W292" : QT_TRANSLATE_NOOP("pep8", 206 "W292": QT_TRANSLATE_NOOP("pep8",
207 "no newline at end of file"), 207 "no newline at end of file"),
208 "W293" : QT_TRANSLATE_NOOP("pep8", 208 "W293": QT_TRANSLATE_NOOP("pep8",
209 "blank line contains whitespace"), 209 "blank line contains whitespace"),
210 "E301" : QT_TRANSLATE_NOOP("pep8", 210 "E301": QT_TRANSLATE_NOOP("pep8",
211 "expected 1 blank line, found 0"), 211 "expected 1 blank line, found 0"),
212 "E302" : QT_TRANSLATE_NOOP("pep8", 212 "E302": QT_TRANSLATE_NOOP("pep8",
213 "expected 2 blank lines, found {0}"), 213 "expected 2 blank lines, found {0}"),
214 "E303" : QT_TRANSLATE_NOOP("pep8", 214 "E303": QT_TRANSLATE_NOOP("pep8",
215 "too many blank lines ({0})"), 215 "too many blank lines ({0})"),
216 "E304" : QT_TRANSLATE_NOOP("pep8", 216 "E304": QT_TRANSLATE_NOOP("pep8",
217 "blank lines found after function decorator"), 217 "blank lines found after function decorator"),
218 "W391" : QT_TRANSLATE_NOOP("pep8", 218 "W391": QT_TRANSLATE_NOOP("pep8",
219 "blank line at end of file"), 219 "blank line at end of file"),
220 "E401" : QT_TRANSLATE_NOOP("pep8", 220 "E401": QT_TRANSLATE_NOOP("pep8",
221 "multiple imports on one line"), 221 "multiple imports on one line"),
222 "E501" : QT_TRANSLATE_NOOP("pep8", 222 "E501": QT_TRANSLATE_NOOP("pep8",
223 "line too long ({0} characters)"), 223 "line too long ({0} characters)"),
224 "W601" : QT_TRANSLATE_NOOP("pep8", 224 "W601": QT_TRANSLATE_NOOP("pep8",
225 ".has_key() is deprecated, use 'in'"), 225 ".has_key() is deprecated, use 'in'"),
226 "W602" : QT_TRANSLATE_NOOP("pep8", 226 "W602": QT_TRANSLATE_NOOP("pep8",
227 "deprecated form of raising exception"), 227 "deprecated form of raising exception"),
228 "W603" : QT_TRANSLATE_NOOP("pep8", 228 "W603": QT_TRANSLATE_NOOP("pep8",
229 "'<>' is deprecated, use '!='"), 229 "'<>' is deprecated, use '!='"),
230 "W604" : QT_TRANSLATE_NOOP("pep8", 230 "W604": QT_TRANSLATE_NOOP("pep8",
231 "backticks are deprecated, use 'repr()'"), 231 "backticks are deprecated, use 'repr()'"),
232 "E701" : QT_TRANSLATE_NOOP("pep8", 232 "E701": QT_TRANSLATE_NOOP("pep8",
233 "multiple statements on one line (colon)"), 233 "multiple statements on one line (colon)"),
234 "E702" : QT_TRANSLATE_NOOP("pep8", 234 "E702": QT_TRANSLATE_NOOP("pep8",
235 "multiple statements on one line (semicolon)"), 235 "multiple statements on one line (semicolon)"),
236 } 236 }
237 237
238 pep8_messages_sample_args = { 238 pep8_messages_sample_args = {
239 "E201" : ["([{"], 239 "E201": ["([{"],
240 "E202" : ["}])"], 240 "E202": ["}])"],
241 "E203" : [",;:"], 241 "E203": [",;:"],
242 "E211" : ["(["], 242 "E211": ["(["],
243 "E231" : [",;:"], 243 "E231": [",;:"],
244 "E241" : [",;:"], 244 "E241": [",;:"],
245 "E242" : [",;:"], 245 "E242": [",;:"],
246 "E302" : [1], 246 "E302": [1],
247 "E303" : [3], 247 "E303": [3],
248 "E501" : [85], 248 "E501": [85],
249 } 249 }
250 250
251 251
252 def getMessage(code, *args): 252 def getMessage(code, *args):
253 """ 253 """
985 self.indent_char = line[0] 985 self.indent_char = line[0]
986 for name, check, argument_names in options.physical_checks: 986 for name, check, argument_names in options.physical_checks:
987 result = self.run_check(check, argument_names) 987 result = self.run_check(check, argument_names)
988 if result is not None: 988 if result is not None:
989 offset, code, *args = result 989 offset, code, *args = result
990 self.report_error_args(self.line_number, offset, code, check, 990 self.report_error_args(self.line_number, offset, code, check,
991 *args) 991 *args)
992 992
993 def build_tokens_line(self): 993 def build_tokens_line(self):
994 """ 994 """
995 Build a logical line from tokens. 995 Build a logical line from tokens.

eric ide

mercurial