From 7666c966d54522aabad8be135a5793bd432e78eb Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Tue, 8 Nov 2022 03:03:02 +0000 Subject: Publish hjson files as json (#18996) --- lib/python/qmk/cli/generate/api.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/python/qmk/cli/generate') diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py index ddb3a0772e..a98a12b628 100755 --- a/lib/python/qmk/cli/generate/api.py +++ b/lib/python/qmk/cli/generate/api.py @@ -27,6 +27,23 @@ def _resolve_keycode_specs(output_folder): output_file = output_folder / f'constants/keycodes_{version}.json' output_file.write_text(json.dumps(overall, indent=4), encoding='utf-8') + # Purge files consumed by 'load_spec' + shutil.rmtree(output_folder / 'constants/keycodes/') + + +def _filtered_copy(src, dst): + src = Path(src) + dst = Path(dst) + + if dst.suffix == '.hjson': + data = json_load(src) + + dst = dst.with_suffix('.json') + dst.write_text(json.dumps(data, indent=4), encoding='utf-8') + return dst + + return shutil.copy2(src, dst) + def _filtered_keyboard_list(): """Perform basic filtering of list_keyboards @@ -58,7 +75,7 @@ def generate_api(cli): shutil.rmtree(BUILD_API_PATH) shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH) - shutil.copytree(DATA_PATH, v1_dir) + shutil.copytree(DATA_PATH, v1_dir, copy_function=_filtered_copy) # Filter down when required keyboard_list = _filtered_keyboard_list() -- cgit v1.2.3