2
# -*- coding: utf-8 -*-
5
"""This script runs pyformat over the code base."""
11
from subprocess import call
15
p = argparse.ArgumentParser(
16
description='Run pyformat over the code base.'
17
' Recurses over all relevant files.')
21
def find_files(startpath, extensions):
22
for (dirpath, _, filenames) in os.walk(startpath):
23
for filename in filenames:
24
if os.path.splitext(filename)[-1].lower() in extensions:
25
yield os.path.join(dirpath, filename)
31
if not os.path.isdir('pybb') or not os.path.isdir('_ops'):
32
print('CWD is not the root of the repository.')
35
sys.stdout.write('\nFormatting Python code ')
36
for filename in find_files('.', ['.py']):
39
call(['pyformat', '-i', filename])
42
print('Formatting finished.')
45
if __name__ == '__main__':