diff options
author | skullY <skullydazed@gmail.com> | 2019-08-22 09:40:12 -0700 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-09-07 07:58:41 -0700 |
commit | deb6fa6a87b12fcdbf577837c6faeb854cd287c7 (patch) | |
tree | 59037fc2c2bb3f096caa7bce3a19261896b2a218 /lib/python/qmk/cli/pyformat.py | |
parent | 533d6d6a464d41d23a39cecfe42d95d2e400d335 (diff) | |
download | qmk_firmware-deb6fa6a87b12fcdbf577837c6faeb854cd287c7.tar.gz qmk_firmware-deb6fa6a87b12fcdbf577837c6faeb854cd287c7.zip |
Add a command to format python code
Diffstat (limited to 'lib/python/qmk/cli/pyformat.py')
-rwxr-xr-x | lib/python/qmk/cli/pyformat.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/pyformat.py b/lib/python/qmk/cli/pyformat.py new file mode 100755 index 000000000..b1f8c02b2 --- /dev/null +++ b/lib/python/qmk/cli/pyformat.py | |||
@@ -0,0 +1,16 @@ | |||
1 | """Format python code according to QMK's style. | ||
2 | """ | ||
3 | from milc import cli | ||
4 | |||
5 | import subprocess | ||
6 | |||
7 | |||
8 | @cli.entrypoint("Format python code according to QMK's style.") | ||
9 | def main(cli): | ||
10 | """Format python code according to QMK's style. | ||
11 | """ | ||
12 | try: | ||
13 | subprocess.run(['yapf', '-vv', '-ri', 'bin/qmk', 'lib/python'], check=True) | ||
14 | cli.log.info('Successfully formatted the python code in `bin/qmk` and `lib/python`.') | ||
15 | except subprocess.CalledProcessError: | ||
16 | cli.log.error('Error formatting python code!') | ||