Add support for qmk_configurator style aliases (#11954)
* Add support for qmk_configurator style aliases * add the keyboard aliases to the api data * add support for a keyboard metadata file * make flake8 happy
This commit is contained in:
parent
723d9af04d
commit
299008be36
18 changed files with 614 additions and 106 deletions
|
@ -7,7 +7,9 @@ import os
|
|||
from glob import glob
|
||||
|
||||
from qmk.c_parse import parse_config_h_file
|
||||
from qmk.json_schema import json_load
|
||||
from qmk.makefile import parse_rules_mk_file
|
||||
from qmk.path import is_keyboard
|
||||
|
||||
BOX_DRAWING_CHARACTERS = {
|
||||
"unicode": {
|
||||
|
@ -31,6 +33,28 @@ BOX_DRAWING_CHARACTERS = {
|
|||
base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep
|
||||
|
||||
|
||||
def keyboard_folder(keyboard):
|
||||
"""Returns the actual keyboard folder.
|
||||
|
||||
This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard.
|
||||
"""
|
||||
aliases = json_load(Path('data/mappings/keyboard_aliases.json'))
|
||||
|
||||
if keyboard in aliases:
|
||||
keyboard = aliases[keyboard].get('target', keyboard)
|
||||
|
||||
rules_mk_file = Path(base_path, keyboard, 'rules.mk')
|
||||
|
||||
if rules_mk_file.exists():
|
||||
rules_mk = parse_rules_mk_file(rules_mk_file)
|
||||
keyboard = rules_mk.get('DEFAULT_FOLDER', keyboard)
|
||||
|
||||
if not is_keyboard(keyboard):
|
||||
raise ValueError(f'Invalid keyboard: {keyboard}')
|
||||
|
||||
return keyboard
|
||||
|
||||
|
||||
def _find_name(path):
|
||||
"""Determine the keyboard name by stripping off the base_path and rules.mk.
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue