def jshint(opts, paths): line_pat = re.compile( ' (?P<path> .+?) :\s' 'line. (?P<lineno> \d+) ,\scol.\d+,' '\s (?P<message> .+)' , re.VERBOSE ) assert len(paths)==1 cmd = ['jshint', '--show-non-errors', '--verbose', paths[0]] p = subprocess.Popen( cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE ) for line in open(paths[0]): if '{%' in line or '{{' in line: line = '// '+line p.stdin.write(line) p.stdin.write('\n') p.stdin.close() status = p.wait() lines = p.stdout.readlines() notes = ifilter(None, imap(line_pat.search, lines)) n_errors = 0 for note in notes: if opts.verbose: print note.groupdict() n_errors += 1 print e_overlay( lineno=note.group('lineno'), face='flynote-pylint-{0}'.format('warning'), message=note.group('message'), ) print e_status('E{0}'.format(n_errors) if n_errors else None)
def jslint(opts, paths): assert len(paths)==1 p = subprocess.Popen( # pylint: disable=E1103 ['jshint', '--verbose', paths[0]], stderr=subprocess.STDOUT, ) status = p.wait() lines = p.stdout.split('\n') line_pat = re.compile( '" (?P<path> .+?)"' ',.line.(?P<lineno> \d+)' ':\s+ (?P<message> .+)' , re.VERBOSE ) notes = ifilter(None, imap(line_pat.search, lines)) notes = ifilter(lambda m: '/jslint.js' not in m.group('path'), notes) n_errors = 0 for note in notes: if opts.verbose: print note.groupdict() n_errors += 1 print e_overlay( lineno=note.group('lineno'), face='flynote-pylint-{0}'.format('warning'), message=note.group('message'), ) print e_status('E{0}'.format(n_errors) if n_errors else None)
def make_overlay(lintrec): msgid = lintrec["code"] + lintrec["id"] return e_overlay( lineno=lintrec["lineno"], face="flynote-pylint-{0}".format(CODE_STYLE.get(lintrec["code"]) or "error"), message=lintrec["message"], obj=lintrec.get("object") or None, msgid=msgid if msgid else None, )