summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/generate
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2023-03-29 12:01:55 +0000
committerQMK Bot <hello@qmk.fm>2023-03-29 12:01:55 +0000
commit66f19518b40afc1f99fc8ee3743dca2b34e92de2 (patch)
treeea6d28d8507275be38c6a6ef5cc009a6fb58c1fa /lib/python/qmk/cli/generate
parent2026165d8ce64971b541ec68192a65f546b0b8b3 (diff)
parentf56580404d44af8a0e8b7205618c084a9acb3772 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/cli/generate')
-rwxr-xr-xlib/python/qmk/cli/generate/api.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py
index cfea3f3946..61a2f9f732 100755
--- a/lib/python/qmk/cli/generate/api.py
+++ b/lib/python/qmk/cli/generate/api.py
@@ -8,7 +8,6 @@ from milc import cli
from qmk.datetime import current_datetime
from qmk.info import info_json
-from qmk.json_encoders import InfoJSONEncoder
from qmk.json_schema import json_load
from qmk.keymap import list_keymaps
from qmk.keyboard import find_readme, list_keyboards
@@ -43,14 +42,14 @@ def _resolve_keycode_specs(output_folder):
overall = load_spec(version)
output_file = output_folder / f'constants/keycodes_{version}.json'
- output_file.write_text(json.dumps(overall), encoding='utf-8')
+ output_file.write_text(json.dumps(overall, separators=(',', ':')), encoding='utf-8')
for lang in list_languages():
for version in list_versions(lang):
overall = load_spec(version, lang)
output_file = output_folder / f'constants/keycodes_{lang}_{version}.json'
- output_file.write_text(json.dumps(overall, indent=4), encoding='utf-8')
+ output_file.write_text(json.dumps(overall, separators=(',', ':')), encoding='utf-8')
# Purge files consumed by 'load_spec'
shutil.rmtree(output_folder / 'constants/keycodes/')
@@ -64,7 +63,7 @@ def _filtered_copy(src, dst):
data = json_load(src)
dst = dst.with_suffix('.json')
- dst.write_text(json.dumps(data), encoding='utf-8')
+ dst.write_text(json.dumps(data, separators=(',', ':')), encoding='utf-8')
return dst
if dst.suffix == '.jsonschema':
@@ -136,7 +135,7 @@ def generate_api(cli):
}
keyboard_dir.mkdir(parents=True, exist_ok=True)
- keyboard_json = json.dumps({'last_updated': current_datetime(), 'keyboards': {keyboard_name: kb_json}})
+ keyboard_json = json.dumps({'last_updated': current_datetime(), 'keyboards': {keyboard_name: kb_json}}, separators=(',', ':'))
if not cli.args.dry_run:
keyboard_info.write_text(keyboard_json, encoding='utf-8')
cli.log.debug('Wrote file %s', keyboard_info)
@@ -150,7 +149,7 @@ def generate_api(cli):
keymap_hjson = kb_json['keymaps'][keymap]['path']
keymap_json = v1_dir / keymap_hjson
keymap_json.parent.mkdir(parents=True, exist_ok=True)
- keymap_json.write_text(json.dumps(json_load(Path(keymap_hjson))), encoding='utf-8')
+ keymap_json.write_text(json.dumps(json_load(Path(keymap_hjson)), separators=(',', ':')), encoding='utf-8')
cli.log.debug('Wrote keymap %s', keymap_json)
if 'usb' in kb_json:
@@ -179,12 +178,12 @@ def generate_api(cli):
_resolve_keycode_specs(v1_dir)
# Write the global JSON files
- keyboard_all_json = json.dumps({'last_updated': current_datetime(), 'keyboards': kb_all}, cls=InfoJSONEncoder)
- usb_json = json.dumps({'last_updated': current_datetime(), 'usb': usb_list}, cls=InfoJSONEncoder)
- keyboard_list_json = json.dumps({'last_updated': current_datetime(), 'keyboards': keyboard_list}, cls=InfoJSONEncoder)
- keyboard_aliases_json = json.dumps({'last_updated': current_datetime(), 'keyboard_aliases': keyboard_aliases}, cls=InfoJSONEncoder)
- keyboard_metadata_json = json.dumps(keyboard_metadata, cls=InfoJSONEncoder)
- constants_metadata_json = json.dumps({'last_updated': current_datetime(), 'constants': _list_constants(v1_dir)})
+ keyboard_all_json = json.dumps({'last_updated': current_datetime(), 'keyboards': kb_all}, separators=(',', ':'))
+ usb_json = json.dumps({'last_updated': current_datetime(), 'usb': usb_list}, separators=(',', ':'))
+ keyboard_list_json = json.dumps({'last_updated': current_datetime(), 'keyboards': keyboard_list}, separators=(',', ':'))
+ keyboard_aliases_json = json.dumps({'last_updated': current_datetime(), 'keyboard_aliases': keyboard_aliases}, separators=(',', ':'))
+ keyboard_metadata_json = json.dumps(keyboard_metadata, separators=(',', ':'))
+ constants_metadata_json = json.dumps({'last_updated': current_datetime(), 'constants': _list_constants(v1_dir)}, separators=(',', ':'))
if not cli.args.dry_run:
keyboard_all_file.write_text(keyboard_all_json, encoding='utf-8')