keyboard stuff
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Update json2c to use dump_lines (#21013)

authored by

Joel Challis and committed by
GitHub
fb056c54 595f7db3

+5 -18
+3 -16
lib/python/qmk/cli/json2c.py
··· 5 5 6 6 import qmk.keymap 7 7 import qmk.path 8 - from qmk.commands import parse_configurator_json 8 + from qmk.commands import dump_lines, parse_configurator_json 9 9 10 10 11 11 @cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') ··· 21 21 # Parse the configurator from json file (or stdin) 22 22 user_keymap = parse_configurator_json(cli.args.filename) 23 23 24 - # Environment processing 25 - if cli.args.output and cli.args.output.name == '-': 26 - cli.args.output = None 27 - 28 24 # Generate the keymap 29 25 keymap_c = qmk.keymap.generate_c(user_keymap) 30 26 31 - if cli.args.output: 32 - cli.args.output.parent.mkdir(parents=True, exist_ok=True) 33 - if cli.args.output.exists(): 34 - cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak')) 35 - cli.args.output.write_text(keymap_c) 36 - 37 - if not cli.args.quiet: 38 - cli.log.info('Wrote keymap to %s.', cli.args.output) 39 - 40 - else: 41 - print(keymap_c) 27 + # Show the results 28 + dump_lines(cli.args.output, keymap_c.split('\n'), cli.args.quiet)
+2 -2
lib/python/qmk/tests/test_cli_commands.py
··· 144 144 def test_json2c(): 145 145 result = check_subcommand('json2c', 'keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json') 146 146 check_returncode(result) 147 - assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n' 147 + assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n\n' 148 148 149 149 150 150 def test_json2c_macros(): ··· 158 158 def test_json2c_stdin(): 159 159 result = check_subcommand_stdin('keyboards/handwired/pytest/has_template/keymaps/default_json/keymap.json', 'json2c', '-') 160 160 check_returncode(result) 161 - assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n' 161 + assert result.stdout == '#include QMK_KEYBOARD_H\nconst uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {\t[0] = LAYOUT_ortho_1x1(KC_A)};\n\n\n' 162 162 163 163 164 164 def test_json2c_wrong_json():