Skip to content

Commit

Permalink
Publish hjson files as json (qmk#18996)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored and ramonimbao committed Nov 28, 2022
1 parent e55557a commit 62485fa
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/python/qmk/cli/generate/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 62485fa

Please sign in to comment.