Allow specific files to be checked by lint-all.

(imported from commit a17800e3ab079e95033243bc82446737dc456b68)
This commit is contained in:
Steve Howell 2013-11-27 13:30:44 -05:00
parent 95320b7369
commit 72e2fbd725
1 changed files with 11 additions and 3 deletions

View File

@ -35,12 +35,16 @@ api/setup.py
""".split()
# Categorize by language all files known to Git
if args:
files = args
else:
# If no files are specified on the command line, use the entire git checkout
files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n'))
git_files = map(str.strip, subprocess.check_output(['git', 'ls-files']).split('\n'))
# Categorize by language all files we want to check
by_lang = defaultdict(list)
for filepath in git_files:
for filepath in files:
if (not filepath or not path.isfile(filepath)
or (filepath in exclude_files)
or any(filepath.startswith(d+'/') for d in exclude_trees)):
@ -111,6 +115,8 @@ logger = logging.getLogger()
logger.setLevel(logging.WARNING)
def check_pyflakes():
if not by_lang['.py']:
return False
failed = False
pyflakes = subprocess.Popen(['pyflakes'] + by_lang['.py'],
stdout = subprocess.PIPE,
@ -187,6 +193,8 @@ try:
@lint
def puppet():
if not by_lang['.pp']:
return 0
result = subprocess.call(['puppet', 'parser', 'validate'] + by_lang['.pp'])
return result