in tools/check_boilerplate.py [0:0]
def main(dir):
"Cycle through files in dir and check for the Apache 2.0 boilerplate."
errors, warnings = [], []
for root, dirs, files in os.walk(dir):
dirs[:] = [d for d in dirs if d not in _EXCLUDE_DIRS]
for fname in files:
if fname in _MATCH_FILES or os.path.splitext(fname)[1] in _MATCH_FILES:
fpath = os.path.abspath(os.path.join(root, fname))
content = open(fpath).read()
if _EXCLUDE_RE.search(content):
continue
try:
if not _MATCH_RE.search(content):
errors.append(fpath)
except (IOError, OSError):
warnings.append(fpath)
if warnings:
print('The following files cannot be accessed:')
print('\n'.join(' - {}'.format(s) for s in warnings))
if errors:
# print('The following files are missing the license boilerplate:')
# print('\n'.join(' - {}'.format(s) for s in errors))
return errors