예제 #1
0
"""Linters process files or lists of files for correctness."""

import cStringIO
import itertools
import os
import re
import subprocess
import sys

import lint_util

# Add vendor path so we can find (our packaged versions of) pep8 and pyflakes.
_CWD = lint_util.get_real_cwd()
_parent_dir = os.path.abspath(_CWD)
_vendor_dir = os.path.join(_parent_dir, 'vendor')
sys.path.append(_vendor_dir)

import static_content_refs
import pep8
from pyflakes.scripts import pyflakes


class Linter(object):
    """Superclass for all linters.

    When subclassing, override either process_files or process (or both,
    though if you override process_files then it doesn't matter what
    process does).
    """
    def process_files(self, files):
        """Print lint errors for a list of filenames and return error count."""
예제 #2
0
import fcntl
import fnmatch
import optparse
import os
import re
import subprocess
import sys
import time

import linters
import lint_util

_DEFAULT_BLACKLIST_PATTERN = '<ancestor>/lint_blacklist.txt'
_DEFAULT_EXTRA_LINTER = '<ancestor>/tools/runlint.py'
_CWD = lint_util.get_real_cwd()

_BLACKLIST_CACHE = {}    # map from filename to its parsed contents (a set)


def _parse_one_blacklist_line(line):
    if line.endswith('/'):
        # When blacklisting a directory, we add two entries: one for the
        # directory name itself (to make pruning easier), and one for the
        # entire directory tree (as a regexp).  This recursive call does
        # the first of these.
        retval = _parse_one_blacklist_line(line[:-1])
    # If the code below this line has horrible syntax highlighting, check
    # this out:  http://stackoverflow.com/questions/13210816/sublime-texts-syntax-highlighting-of-regexes-in-python-leaks-into-surrounding-c
    elif not re.search(r'[[*?!]', line):
        # Easy case: no char meaningful to glob()