Add include and exclude handling to the js style-checker.

--include and --exclude now accept unix shell-style patterns.

refs #4244
This commit is contained in:
Johannes Meyer 2013-06-07 11:24:14 +02:00 committed by Eric Lippmann
parent 7c779bc525
commit 7e14a2077d
1 changed files with 15 additions and 3 deletions

View File

@ -3,6 +3,7 @@
import os
import sys
import subprocess
from fnmatch import fnmatch
from optparse import OptionParser, BadOptionError, AmbiguousOptionError
@ -96,10 +97,21 @@ def main():
if os.path.isfile(a) or os.path.isdir(a)]
if not path_args:
path_args = ['../../application', '../../bin', '../../library/Icinga']
if options.include:
path_args = [os.path.join(r, f) for a in path_args
for r, _, fs in os.walk(a)
for f in fs
if any(fnmatch(os.path.join(r, f), p)
for p in options.include)]
if options.exclude:
pass # TODO: Preprocess disallowed files/directories
elif options.include:
pass # TODO: Preprocess allowed files/directories
walk = lambda p: os.walk(p) if os.path.isdir(p) else \
[(os.path.dirname(p), None, [os.path.basename(p)])]
path_args = [os.path.join(r, f)
for a in path_args
for r, _, fs in walk(a)
for f in fs
if not any(fnmatch(os.path.join(r, f), p)
for p in options.exclude)]
# Application invocation..
if options.build: