Align filenames

This commit is contained in:
zvecr
2022-05-23 02:14:42 +01:00
parent e04e31cde7
commit f2d56f5ca1
4 changed files with 68 additions and 34 deletions
+24 -22
View File
@@ -12,6 +12,8 @@ from qmk.decorators import lru_cache
from qmk.keymap import locate_keymap
from qmk.path import keyboard
XAP_SPEC = 'xap.hjson'
def _get_jinja2_env(data_templates_xap_subdir: str):
templates_dir = os.path.join(QMK_FIRMWARE, 'data', 'templates', 'xap', data_templates_xap_subdir)
@@ -24,6 +26,28 @@ def render_xap_output(data_templates_xap_subdir, file_to_render, defs):
return j2.get_template(file_to_render).render(xap=defs, xap_str=hjson.dumps(defs))
def _find_kb_spec(kb):
base_path = Path('keyboards')
keyboard_parent = keyboard(kb)
for _ in range(5):
if keyboard_parent == base_path:
break
spec = keyboard_parent / XAP_SPEC
if spec.exists():
return spec
keyboard_parent = keyboard_parent.parent
# Just return something we know doesn't exist
return keyboard(kb) / XAP_SPEC
def _find_km_spec(kb, km):
return locate_keymap(kb, km).parent / XAP_SPEC
def _merge_ordered_dicts(dicts):
"""Merges nested OrderedDict objects resulting from reading a hjson file.
@@ -98,28 +122,6 @@ def latest_xap_defs():
return get_xap_defs('latest')
def _find_kb_spec(kb):
base_path = Path('keyboards')
keyboard_parent = keyboard(kb)
for _ in range(5):
if keyboard_parent == base_path:
break
spec = keyboard_parent / 'xap.json'
if spec.exists():
return spec
keyboard_parent = keyboard_parent.parent
# Just return something we know doesn't exist
return keyboard(kb) / 'xap.json'
def _find_km_spec(kb, km):
return locate_keymap(kb, km).parent / 'xap.json'
def merge_xap_defs(kb, km):
"""Gets the latest version of the XAP definitions and merges in optional keyboard/keymap specs
"""