205 ignoreStarImportWarnings=False): |
205 ignoreStarImportWarnings=False): |
206 """ |
206 """ |
207 Function to compile one Python source file to Python bytecode |
207 Function to compile one Python source file to Python bytecode |
208 and to perform a pyflakes check. |
208 and to perform a pyflakes check. |
209 |
209 |
210 @param filename source filename (string) |
210 @param filename source filename |
211 @param codestring string containing the code to compile (string) |
211 @type str |
212 @param checkFlakes flag indicating to do a pyflakes check (boolean) |
212 @param codestring string containing the code to compile |
|
213 @type str |
|
214 @param checkFlakes flag indicating to do a pyflakes check |
|
215 @type bool |
213 @param ignoreStarImportWarnings flag indicating to |
216 @param ignoreStarImportWarnings flag indicating to |
214 ignore 'star import' warnings (boolean) |
217 ignore 'star import' warnings |
|
218 @type bool |
215 @return dictionary with the keys 'error' and 'warnings' which |
219 @return dictionary with the keys 'error' and 'warnings' which |
216 hold a list containing details about the error/ warnings |
220 hold a list containing details about the error/ warnings |
217 (file name, line number, column, codestring (only at syntax |
221 (file name, line number, column, codestring (only at syntax |
218 errors), the message, a list with arguments for the message) |
222 errors), the message, a list with arguments for the message) |
|
223 @rtype dict |
219 """ |
224 """ |
220 import builtins |
225 import builtins |
221 |
226 |
222 try: |
227 try: |
223 codestring = normalizeCode(codestring) |
228 codestring = normalizeCode(codestring) |
294 lines = codestring.splitlines() |
299 lines = codestring.splitlines() |
295 try: |
300 try: |
296 warnings = Checker(module, filename, withDoctest=True) |
301 warnings = Checker(module, filename, withDoctest=True) |
297 warnings.messages.sort(key=lambda a: a.lineno) |
302 warnings.messages.sort(key=lambda a: a.lineno) |
298 for warning in warnings.messages: |
303 for warning in warnings.messages: |
299 if ignoreStarImportWarnings and ( |
304 if ( |
300 isinstance(warning, ImportStarUsed) or |
305 ignoreStarImportWarnings and |
301 isinstance(warning, ImportStarUsage) |
306 isinstance(warning, (ImportStarUsed, ImportStarUsage)) |
302 ): |
307 ): |
303 continue |
308 continue |
304 |
309 |
305 _fn, lineno, col, message, msg_args = warning.getMessageData() |
310 _fn, lineno, col, message, msg_args = warning.getMessageData() |
306 lineFlags = extractLineFlags(lines[lineno - 1].strip()) |
311 lineFlags = extractLineFlags(lines[lineno - 1].strip()) |