give find_files() a filename tester function arg
This commit is contained in:
parent
f5f6d99cd7
commit
cab1b81026
1 changed files with 12 additions and 7 deletions
19
script/cpplint.py
vendored
19
script/cpplint.py
vendored
|
@ -73,24 +73,29 @@ def main():
|
|||
os.chdir(SOURCE_ROOT)
|
||||
files = find_files('atom',
|
||||
['app', 'browser', 'common', 'renderer', 'utility'],
|
||||
['*.cc', '*.h'])
|
||||
files += find_files('brightray', ['browser', 'common'], ['*.cc', '*.h'])
|
||||
is_cpp_file)
|
||||
files |= find_files('brightray', ['browser', 'common'], is_cpp_file)
|
||||
files -= set(IGNORE_FILES)
|
||||
if args.only_changed:
|
||||
files &= find_changed_files()
|
||||
call_cpplint(list(files))
|
||||
|
||||
|
||||
def find_files(parent, directories, filters):
|
||||
def find_files(root, directories, test):
|
||||
matches = set()
|
||||
for directory in directories:
|
||||
for root, _, filenames, in os.walk(os.path.join(parent, directory)):
|
||||
for f in filters:
|
||||
for filename in fnmatch.filter(filenames, f):
|
||||
matches.add(os.path.join(root, filename))
|
||||
for parent, _, children, in os.walk(os.path.join(root, directory)):
|
||||
for child in children:
|
||||
filename = os.path.join(parent,child)
|
||||
if test(filename):
|
||||
matches.add(filename)
|
||||
return matches
|
||||
|
||||
|
||||
def is_cpp_file(filename):
|
||||
return filename.endswith('.cc') or filename.endswith('.h')
|
||||
|
||||
|
||||
def find_changed_files():
|
||||
return set(execute(['git', 'diff', '--name-only']).splitlines())
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue