diff options
| author | QMK Bot <hello@qmk.fm> | 2019-11-16 07:10:19 +0000 |
|---|---|---|
| committer | QMK Bot <hello@qmk.fm> | 2019-11-16 07:10:19 +0000 |
| commit | 7891de7f6d64431cedbd580a3f7863533dc8be88 (patch) | |
| tree | a4fc89d7821126c1d101cf7acea75efcecdbc7a9 /lib | |
| parent | 897888db419239f013561b155de5993b1966820e (diff) | |
| download | qmk_firmware-7891de7f6d64431cedbd580a3f7863533dc8be88.tar.gz qmk_firmware-7891de7f6d64431cedbd580a3f7863533dc8be88.zip | |
format code according to conventions [skip ci]
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/python/qmk/cli/compile.py | 3 | ||||
| -rw-r--r-- | lib/python/qmk/cli/flash.py | 3 | ||||
| -rw-r--r-- | lib/python/qmk/commands.py | 4 | ||||
| -rw-r--r-- | lib/python/qmk/tests/test_cli_commands.py | 2 |
4 files changed, 8 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/compile.py b/lib/python/qmk/cli/compile.py index c7093d421..5c2980009 100755 --- a/lib/python/qmk/cli/compile.py +++ b/lib/python/qmk/cli/compile.py | |||
| @@ -38,13 +38,12 @@ def compile(cli): | |||
| 38 | # Generate the keymap | 38 | # Generate the keymap |
| 39 | keymap_path = qmk.path.keymap(user_keymap['keyboard']) | 39 | keymap_path = qmk.path.keymap(user_keymap['keyboard']) |
| 40 | cli.log.info('Creating {fg_cyan}%s{style_reset_all} keymap in {fg_cyan}%s', user_keymap['keymap'], keymap_path) | 40 | cli.log.info('Creating {fg_cyan}%s{style_reset_all} keymap in {fg_cyan}%s', user_keymap['keymap'], keymap_path) |
| 41 | 41 | ||
| 42 | # Compile the keymap | 42 | # Compile the keymap |
| 43 | command = compile_configurator_json(cli.args.filename) | 43 | command = compile_configurator_json(cli.args.filename) |
| 44 | 44 | ||
| 45 | cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap']) | 45 | cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap']) |
| 46 | 46 | ||
| 47 | |||
| 48 | elif cli.config.compile.keyboard and cli.config.compile.keymap: | 47 | elif cli.config.compile.keyboard and cli.config.compile.keymap: |
| 49 | # Generate the make command for a specific keyboard/keymap. | 48 | # Generate the make command for a specific keyboard/keymap. |
| 50 | command = create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap) | 49 | command = create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap) |
diff --git a/lib/python/qmk/cli/flash.py b/lib/python/qmk/cli/flash.py index 8f7bb55a2..37556aaaf 100644 --- a/lib/python/qmk/cli/flash.py +++ b/lib/python/qmk/cli/flash.py | |||
| @@ -32,6 +32,7 @@ def print_bootloader_help(): | |||
| 32 | cli.echo('\tst-link-cli') | 32 | cli.echo('\tst-link-cli') |
| 33 | cli.echo('For more info, visit https://docs.qmk.fm/#/flashing') | 33 | cli.echo('For more info, visit https://docs.qmk.fm/#/flashing') |
| 34 | 34 | ||
| 35 | |||
| 35 | @cli.argument('-bl', '--bootloader', default='flash', help='The flash command, corresponding to qmk\'s make options of bootloaders.') | 36 | @cli.argument('-bl', '--bootloader', default='flash', help='The flash command, corresponding to qmk\'s make options of bootloaders.') |
| 36 | @cli.argument('filename', nargs='?', arg_only=True, help='The configurator export JSON to compile. Use this if you dont want to specify a keymap and keyboard.') | 37 | @cli.argument('filename', nargs='?', arg_only=True, help='The configurator export JSON to compile. Use this if you dont want to specify a keymap and keyboard.') |
| 37 | @cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.') | 38 | @cli.argument('-km', '--keymap', help='The keymap to build a firmware for. Use this if you dont have a configurator file. Ignored when a configurator file is supplied.') |
| @@ -84,4 +85,4 @@ def flash(cli): | |||
| 84 | return False | 85 | return False |
| 85 | 86 | ||
| 86 | cli.log.info('Flashing keymap with {fg_cyan}%s\n\n', ' '.join(command)) | 87 | cli.log.info('Flashing keymap with {fg_cyan}%s\n\n', ' '.join(command)) |
| 87 | subprocess.run(command) \ No newline at end of file | 88 | subprocess.run(command) |
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 9fbf00f16..f83a89578 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | import json | 3 | import json |
| 4 | import qmk.keymap | 4 | import qmk.keymap |
| 5 | 5 | ||
| 6 | |||
| 6 | def create_make_command(keyboard, keymap, target=None): | 7 | def create_make_command(keyboard, keymap, target=None): |
| 7 | """Create a make compile command | 8 | """Create a make compile command |
| 8 | 9 | ||
| @@ -23,6 +24,7 @@ def create_make_command(keyboard, keymap, target=None): | |||
| 23 | return ['make', ':'.join((keyboard, keymap))] | 24 | return ['make', ':'.join((keyboard, keymap))] |
| 24 | return ['make', ':'.join((keyboard, keymap, target))] | 25 | return ['make', ':'.join((keyboard, keymap, target))] |
| 25 | 26 | ||
| 27 | |||
| 26 | def parse_configurator_json(configurator_filename): | 28 | def parse_configurator_json(configurator_filename): |
| 27 | """Open and parse a configurator json export | 29 | """Open and parse a configurator json export |
| 28 | """ | 30 | """ |
| @@ -31,6 +33,7 @@ def parse_configurator_json(configurator_filename): | |||
| 31 | file.close() | 33 | file.close() |
| 32 | return user_keymap | 34 | return user_keymap |
| 33 | 35 | ||
| 36 | |||
| 34 | def compile_configurator_json(configurator_filename, bootloader=None): | 37 | def compile_configurator_json(configurator_filename, bootloader=None): |
| 35 | """Convert a configurator export JSON file into a C file | 38 | """Convert a configurator export JSON file into a C file |
| 36 | 39 | ||
| @@ -54,4 +57,3 @@ def compile_configurator_json(configurator_filename, bootloader=None): | |||
| 54 | if bootloader is None: | 57 | if bootloader is None: |
| 55 | return create_make_command(user_keymap['keyboard'], user_keymap['keymap']) | 58 | return create_make_command(user_keymap['keyboard'], user_keymap['keymap']) |
| 56 | return create_make_command(user_keymap['keyboard'], user_keymap['keymap'], bootloader) | 59 | return create_make_command(user_keymap['keyboard'], user_keymap['keymap'], bootloader) |
| 57 | |||
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index dcab8bdae..3f75cef3e 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py | |||
| @@ -13,10 +13,12 @@ def test_cformat(): | |||
| 13 | def test_compile(): | 13 | def test_compile(): |
| 14 | assert check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default').returncode == 0 | 14 | assert check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default').returncode == 0 |
| 15 | 15 | ||
| 16 | |||
| 16 | def test_flash(): | 17 | def test_flash(): |
| 17 | assert check_subcommand('flash', '-b').returncode == 1 | 18 | assert check_subcommand('flash', '-b').returncode == 1 |
| 18 | assert check_subcommand('flash').returncode == 1 | 19 | assert check_subcommand('flash').returncode == 1 |
| 19 | 20 | ||
| 21 | |||
| 20 | def test_config(): | 22 | def test_config(): |
| 21 | result = check_subcommand('config') | 23 | result = check_subcommand('config') |
| 22 | assert result.returncode == 0 | 24 | assert result.returncode == 0 |
