summaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli
diff options
context:
space:
mode:
authorJoel Challis <git@zvecr.com>2022-11-08 03:03:02 +0000
committerGitHub <noreply@github.com>2022-11-08 03:03:02 +0000
commit7666c966d54522aabad8be135a5793bd432e78eb (patch)
tree1d7028b8380504e1be94857dfca68e42ced3499f /lib/python/qmk/cli
parent479d8de622674b6667295bda344145a69aa042bd (diff)
Publish hjson files as json (#18996)
Diffstat (limited to 'lib/python/qmk/cli')
-rwxr-xr-xlib/python/qmk/cli/generate/api.py19
1 files changed, 18 insertions, 1 deletions
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):
27 output_file = output_folder / f'constants/keycodes_{version}.json' 27 output_file = output_folder / f'constants/keycodes_{version}.json'
28 output_file.write_text(json.dumps(overall, indent=4), encoding='utf-8') 28 output_file.write_text(json.dumps(overall, indent=4), encoding='utf-8')
29 29
30 # Purge files consumed by 'load_spec'
31 shutil.rmtree(output_folder / 'constants/keycodes/')
32
33
34def _filtered_copy(src, dst):
35 src = Path(src)
36 dst = Path(dst)
37
38 if dst.suffix == '.hjson':
39 data = json_load(src)
40
41 dst = dst.with_suffix('.json')
42 dst.write_text(json.dumps(data, indent=4), encoding='utf-8')
43 return dst
44
45 return shutil.copy2(src, dst)
46
30 47
31def _filtered_keyboard_list(): 48def _filtered_keyboard_list():
32 """Perform basic filtering of list_keyboards 49 """Perform basic filtering of list_keyboards
@@ -58,7 +75,7 @@ def generate_api(cli):
58 shutil.rmtree(BUILD_API_PATH) 75 shutil.rmtree(BUILD_API_PATH)
59 76
60 shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH) 77 shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH)
61 shutil.copytree(DATA_PATH, v1_dir) 78 shutil.copytree(DATA_PATH, v1_dir, copy_function=_filtered_copy)
62 79
63 # Filter down when required 80 # Filter down when required
64 keyboard_list = _filtered_keyboard_list() 81 keyboard_list = _filtered_keyboard_list()