format code according to conventions [skip ci]
This commit is contained in:
parent
897888db41
commit
7891de7f6d
4 changed files with 8 additions and 4 deletions
|
@ -38,13 +38,12 @@ def compile(cli):
|
||||||
# Generate the keymap
|
# Generate the keymap
|
||||||
keymap_path = qmk.path.keymap(user_keymap['keyboard'])
|
keymap_path = qmk.path.keymap(user_keymap['keyboard'])
|
||||||
cli.log.info('Creating {fg_cyan}%s{style_reset_all} keymap in {fg_cyan}%s', user_keymap['keymap'], keymap_path)
|
cli.log.info('Creating {fg_cyan}%s{style_reset_all} keymap in {fg_cyan}%s', user_keymap['keymap'], keymap_path)
|
||||||
|
|
||||||
# Compile the keymap
|
# Compile the keymap
|
||||||
command = compile_configurator_json(cli.args.filename)
|
command = compile_configurator_json(cli.args.filename)
|
||||||
|
|
||||||
cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])
|
cli.log.info('Wrote keymap to {fg_cyan}%s/%s/keymap.c', keymap_path, user_keymap['keymap'])
|
||||||
|
|
||||||
|
|
||||||
elif cli.config.compile.keyboard and cli.config.compile.keymap:
|
elif cli.config.compile.keyboard and cli.config.compile.keymap:
|
||||||
# Generate the make command for a specific keyboard/keymap.
|
# Generate the make command for a specific keyboard/keymap.
|
||||||
command = create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap)
|
command = create_make_command(cli.config.compile.keyboard, cli.config.compile.keymap)
|
||||||
|
|
|
@ -32,6 +32,7 @@ def print_bootloader_help():
|
||||||
cli.echo('\tst-link-cli')
|
cli.echo('\tst-link-cli')
|
||||||
cli.echo('For more info, visit https://docs.qmk.fm/#/flashing')
|
cli.echo('For more info, visit https://docs.qmk.fm/#/flashing')
|
||||||
|
|
||||||
|
|
||||||
@cli.argument('-bl', '--bootloader', default='flash', help='The flash command, corresponding to qmk\'s make options of bootloaders.')
|
@cli.argument('-bl', '--bootloader', default='flash', help='The flash command, corresponding to qmk\'s make options of bootloaders.')
|
||||||
@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.')
|
@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.')
|
||||||
@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.')
|
@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):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
cli.log.info('Flashing keymap with {fg_cyan}%s\n\n', ' '.join(command))
|
cli.log.info('Flashing keymap with {fg_cyan}%s\n\n', ' '.join(command))
|
||||||
subprocess.run(command)
|
subprocess.run(command)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
import json
|
import json
|
||||||
import qmk.keymap
|
import qmk.keymap
|
||||||
|
|
||||||
|
|
||||||
def create_make_command(keyboard, keymap, target=None):
|
def create_make_command(keyboard, keymap, target=None):
|
||||||
"""Create a make compile command
|
"""Create a make compile command
|
||||||
|
|
||||||
|
@ -23,6 +24,7 @@ def create_make_command(keyboard, keymap, target=None):
|
||||||
return ['make', ':'.join((keyboard, keymap))]
|
return ['make', ':'.join((keyboard, keymap))]
|
||||||
return ['make', ':'.join((keyboard, keymap, target))]
|
return ['make', ':'.join((keyboard, keymap, target))]
|
||||||
|
|
||||||
|
|
||||||
def parse_configurator_json(configurator_filename):
|
def parse_configurator_json(configurator_filename):
|
||||||
"""Open and parse a configurator json export
|
"""Open and parse a configurator json export
|
||||||
"""
|
"""
|
||||||
|
@ -31,6 +33,7 @@ def parse_configurator_json(configurator_filename):
|
||||||
file.close()
|
file.close()
|
||||||
return user_keymap
|
return user_keymap
|
||||||
|
|
||||||
|
|
||||||
def compile_configurator_json(configurator_filename, bootloader=None):
|
def compile_configurator_json(configurator_filename, bootloader=None):
|
||||||
"""Convert a configurator export JSON file into a C file
|
"""Convert a configurator export JSON file into a C file
|
||||||
|
|
||||||
|
@ -54,4 +57,3 @@ def compile_configurator_json(configurator_filename, bootloader=None):
|
||||||
if bootloader is None:
|
if bootloader is None:
|
||||||
return create_make_command(user_keymap['keyboard'], user_keymap['keymap'])
|
return create_make_command(user_keymap['keyboard'], user_keymap['keymap'])
|
||||||
return create_make_command(user_keymap['keyboard'], user_keymap['keymap'], bootloader)
|
return create_make_command(user_keymap['keyboard'], user_keymap['keymap'], bootloader)
|
||||||
|
|
||||||
|
|
|
@ -13,10 +13,12 @@ def test_cformat():
|
||||||
def test_compile():
|
def test_compile():
|
||||||
assert check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default').returncode == 0
|
assert check_subcommand('compile', '-kb', 'handwired/onekey/pytest', '-km', 'default').returncode == 0
|
||||||
|
|
||||||
|
|
||||||
def test_flash():
|
def test_flash():
|
||||||
assert check_subcommand('flash', '-b').returncode == 1
|
assert check_subcommand('flash', '-b').returncode == 1
|
||||||
assert check_subcommand('flash').returncode == 1
|
assert check_subcommand('flash').returncode == 1
|
||||||
|
|
||||||
|
|
||||||
def test_config():
|
def test_config():
|
||||||
result = check_subcommand('config')
|
result = check_subcommand('config')
|
||||||
assert result.returncode == 0
|
assert result.returncode == 0
|
||||||
|
|
Loading…
Reference in a new issue