def run_pyflakes(request_data):
global prev_results<EOL>from pyflakes import checker<EOL>import _ast<EOL>WARNING = <NUM_LIT:1><EOL>ERROR = <NUM_LIT:2><EOL>ret_val = []<EOL>code = request_data['<STR_LIT:code>']<EOL>path = request_data['<STR_LIT:path>']<EOL>encoding = request_data['<STR_LIT>']<EOL>if not encoding:<EOL><INDENT>encoding = '<STR_LIT:utf-8>'<EOL><DEDENT>if not path:<EOL><INDENT>path = os.path.join(tempfile.gettempdir(), '<STR_LIT>')<EOL><DEDENT>if not code:<EOL><INDENT>return []<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>tree = compile(code.encode(encoding), path, "<STR_LIT>",<EOL>_ast.PyCF_ONLY_AST)<EOL><DEDENT>except SyntaxError as value:<EOL><INDENT>msg = '<STR_LIT>' % value.args[<NUM_LIT:0>]<EOL>(lineno, offset, text) = value.lineno - <NUM_LIT:1>, value.offset, value.text<EOL>if text is None:<EOL><INDENT>_logger().warning("<STR_LIT>",<EOL>path)<EOL><DEDENT>else:<EOL><INDENT>ret_val.append((msg, ERROR, lineno))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>w = checker.Checker(tree, os.path.split(path)[<NUM_LIT:1>])<EOL>w.messages.sort(key=lambda m: m.lineno)<EOL>for message in w.messages:<EOL><INDENT>msg = "<STR_LIT>" % str(message).split('<STR_LIT::>')[-<NUM_LIT:1>].strip()<EOL>line = message.lineno - <NUM_LIT:1><EOL>status = WARNINGif message.__class__ not in PYFLAKES_ERROR_MESSAGESelse ERROR<EOL>ret_val.append((msg, status, line))<EOL><DEDENT><DEDENT><DEDENT>prev_results = ret_val<EOL>return ret_val<EOL>
Worker that run a frosted (the fork of pyflakes) code analysis on the
current editor text.