summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 11d4616199..580e080eeb 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
return shutil.copy2(src, dst)
@@ -130,7 +129,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)
@@ -144,7 +143,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:
@@ -173,12 +172,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')