1
0
Fork 0

qmk format-json: Expose full key path and respect sort_keys (#20836)

This commit is contained in:
Ryan 2023-05-20 22:15:05 +10:00 committed by GitHub
parent 102c42b14b
commit 6d90fa2300
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 48 additions and 52 deletions

View file

@ -57,7 +57,7 @@ def c2json(cli):
cli.args.output.parent.mkdir(parents=True, exist_ok=True)
if cli.args.output.exists():
cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak'))
cli.args.output.write_text(json.dumps(keymap_json, cls=InfoJSONEncoder))
cli.args.output.write_text(json.dumps(keymap_json, cls=InfoJSONEncoder, sort_keys=True))
if not cli.args.quiet:
cli.log.info('Wrote keymap to %s.', cli.args.output)

View file

@ -62,4 +62,4 @@ def format_json(cli):
json_file['layers'][layer_num] = current_layer
# Display the results
print(json.dumps(json_file, cls=json_encoder))
print(json.dumps(json_file, cls=json_encoder, sort_keys=True))

View file

@ -76,7 +76,7 @@ def generate_info_json(cli):
# Build the info.json file
kb_info_json = info_json(cli.config.generate_info_json.keyboard)
strip_info_json(kb_info_json)
info_json_text = json.dumps(kb_info_json, indent=4, cls=InfoJSONEncoder)
info_json_text = json.dumps(kb_info_json, indent=4, cls=InfoJSONEncoder, sort_keys=True)
if cli.args.output:
# Write to a file

View file

@ -200,7 +200,7 @@ def info(cli):
# Output in the requested format
if cli.args.format == 'json':
print(json.dumps(kb_info_json, cls=InfoJSONEncoder))
print(json.dumps(kb_info_json, cls=InfoJSONEncoder, sort_keys=True))
return True
elif cli.args.format == 'text':
print_dotted_output(kb_info_json)

View file

@ -75,7 +75,7 @@ def migrate(cli):
# Finally write out updated info.json
cli.log.info(f' Updating {target_info}')
target_info.write_text(json.dumps(info_data.to_dict(), cls=InfoJSONEncoder))
target_info.write_text(json.dumps(info_data.to_dict(), cls=InfoJSONEncoder, sort_keys=True))
cli.log.info(f'{{fg_green}}Migration of keyboard {{fg_cyan}}{cli.args.keyboard}{{fg_green}} complete!{{fg_reset}}')
cli.log.info(f"Verify build with {{fg_yellow}}qmk compile -kb {cli.args.keyboard} -km default{{fg_reset}}.")

View file

@ -102,7 +102,7 @@ def augment_community_info(src, dest):
item["matrix"] = [int(item["y"]), int(item["x"])]
# finally write out the updated info.json
dest.write_text(json.dumps(info, cls=InfoJSONEncoder))
dest.write_text(json.dumps(info, cls=InfoJSONEncoder, sort_keys=True))
def _question(*args, **kwargs):

View file

@ -141,5 +141,5 @@ def via2json(cli):
# Generate the keymap.json
keymap_json = generate_json(cli.args.keymap, cli.args.keyboard, keymap_layout, keymap_data, macro_data)
keymap_lines = [json.dumps(keymap_json, cls=KeymapJSONEncoder)]
keymap_lines = [json.dumps(keymap_json, cls=KeymapJSONEncoder, sort_keys=True)]
dump_lines(cli.args.output, keymap_lines, cli.args.quiet)