Пример #1
0
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)
Пример #2
0
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)
Пример #3
0
def pylint(opts, paths):
    lines = run_pylint(paths)
    if opts.verbose:
        lines = list(lines)
        print "Pylint output:"
        print "\n".join(lines)
    lintrecs = list(filter_recs(parse(lines)))
    lintrecs = list(findobj_recs(lintrecs))
    enotes = ifilter(None, (make_overlay(rec) for rec in lintrecs))
    print "\n".join(enotes)

    stats = calc_stats(lintrecs)
    statlabel = make_statlabel(stats)
    print e_status("pylint: {0}".format(statlabel or "okay"))