diff options
author | skullY <skullydazed@gmail.com> | 2019-08-22 13:33:34 -0700 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2019-08-31 08:50:25 -0700 |
commit | 2d688ad14e727bd3437f26a53bd3d92079e5b3c2 (patch) | |
tree | ec0ed5538e19a97337f53308680aedb9fda43e45 /lib/python | |
parent | 1784d1bfac44a63bf343b6e2098f0cba81d58cb2 (diff) | |
download | qmk_firmware-2d688ad14e727bd3437f26a53bd3d92079e5b3c2.tar.gz qmk_firmware-2d688ad14e727bd3437f26a53bd3d92079e5b3c2.zip |
readability enhancements
Diffstat (limited to 'lib/python')
-rw-r--r-- | lib/python/qmk/cli/cformat.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/python/qmk/cli/cformat.py b/lib/python/qmk/cli/cformat.py index 0c209247d..91e650368 100644 --- a/lib/python/qmk/cli/cformat.py +++ b/lib/python/qmk/cli/cformat.py | |||
@@ -12,18 +12,23 @@ def main(cli): | |||
12 | """Format C code according to QMK's style. | 12 | """Format C code according to QMK's style. |
13 | """ | 13 | """ |
14 | clang_format = ['clang-format', '-i'] | 14 | clang_format = ['clang-format', '-i'] |
15 | |||
16 | # Find the list of files to format | ||
15 | if not cli.args.files: | 17 | if not cli.args.files: |
16 | for dir in ['drivers', 'quantum', 'tests', 'tmk_core']: | 18 | for dir in ['drivers', 'quantum', 'tests', 'tmk_core']: |
17 | for dirpath, dirnames, filenames in os.walk(dir): | 19 | for dirpath, dirnames, filenames in os.walk(dir): |
18 | if 'tmk_core/protocol/usb_hid' in dirpath: | 20 | if 'tmk_core/protocol/usb_hid' in dirpath: |
19 | continue | 21 | continue |
22 | |||
20 | for name in filenames: | 23 | for name in filenames: |
21 | if name.endswith('.c') or name.endswith('.h') or name.endswith('.cpp'): | 24 | if name.endswith('.c') or name.endswith('.h') or name.endswith('.cpp'): |
22 | cli.args.files.append(os.path.join(dirpath, name)) | 25 | cli.args.files.append(os.path.join(dirpath, name)) |
23 | 26 | ||
27 | # Run clang-format on the files we've found | ||
24 | try: | 28 | try: |
25 | subprocess.run(clang_format + cli.args.files, check=True) | 29 | subprocess.run(clang_format + cli.args.files, check=True) |
26 | cli.log.info('Successfully formatted the C code.') | 30 | cli.log.info('Successfully formatted the C code.') |
31 | |||
27 | except subprocess.CalledProcessError: | 32 | except subprocess.CalledProcessError: |
28 | cli.log.error('Error formatting C code!') | 33 | cli.log.error('Error formatting C code!') |
29 | return False | 34 | return False |