From deb6fa6a87b12fcdbf577837c6faeb854cd287c7 Mon Sep 17 00:00:00 2001 From: skullY Date: Thu, 22 Aug 2019 09:40:12 -0700 Subject: Add a command to format python code --- lib/python/qmk/cli/pyformat.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100755 lib/python/qmk/cli/pyformat.py (limited to 'lib/python/qmk/cli/pyformat.py') diff --git a/lib/python/qmk/cli/pyformat.py b/lib/python/qmk/cli/pyformat.py new file mode 100755 index 0000000000..b1f8c02b28 --- /dev/null +++ b/lib/python/qmk/cli/pyformat.py @@ -0,0 +1,16 @@ +"""Format python code according to QMK's style. +""" +from milc import cli + +import subprocess + + +@cli.entrypoint("Format python code according to QMK's style.") +def main(cli): + """Format python code according to QMK's style. + """ + try: + subprocess.run(['yapf', '-vv', '-ri', 'bin/qmk', 'lib/python'], check=True) + cli.log.info('Successfully formatted the python code in `bin/qmk` and `lib/python`.') + except subprocess.CalledProcessError: + cli.log.error('Error formatting python code!') -- cgit v1.2.3