diff options
author | Nick Brassel <[email protected]> | 2023-11-28 07:53:43 +1100 |
---|---|---|
committer | GitHub <[email protected]> | 2023-11-28 07:53:43 +1100 |
commit | 5501e804ff8d41ce656061b91896c4ac8c681d78 (patch) | |
tree | 6a655fbceaeab67cf727dbe4318721407dd31824 /lib/python/qmk/keyboard.py | |
parent | 094357c40347e8a5db36578851f1af34a92e9f68 (diff) | |
download | qmk_firmware-5501e804ff8d41ce656061b91896c4ac8c681d78.tar.gz qmk_firmware-5501e804ff8d41ce656061b91896c4ac8c681d78.zip |
QMK Userspace (#22222)
Co-authored-by: Duncan Sutherland <[email protected]>
Diffstat (limited to 'lib/python/qmk/keyboard.py')
-rw-r--r-- | lib/python/qmk/keyboard.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py index 34257bee8d..b56505d649 100644 --- a/lib/python/qmk/keyboard.py +++ b/lib/python/qmk/keyboard.py @@ -78,13 +78,17 @@ def keyboard_alias_definitions(): def is_all_keyboards(keyboard): """Returns True if the keyboard is an AllKeyboards object. """ + if isinstance(keyboard, str): + return (keyboard == 'all') return isinstance(keyboard, AllKeyboards) def find_keyboard_from_dir(): """Returns a keyboard name based on the user's current directory. """ - relative_cwd = qmk.path.under_qmk_firmware() + relative_cwd = qmk.path.under_qmk_userspace() + if not relative_cwd: + relative_cwd = qmk.path.under_qmk_firmware() if relative_cwd and len(relative_cwd.parts) > 1 and relative_cwd.parts[0] == 'keyboards': # Attempt to extract the keyboard name from the current directory @@ -133,6 +137,22 @@ def keyboard_folder(keyboard): return keyboard +def keyboard_aliases(keyboard): + """Returns the list of aliases for the supplied keyboard. + + Includes the keyboard itself. + """ + aliases = json_load(Path('data/mappings/keyboard_aliases.hjson')) + + if keyboard in aliases: + keyboard = aliases[keyboard].get('target', keyboard) + + keyboards = set(filter(lambda k: aliases[k].get('target', '') == keyboard, aliases.keys())) + keyboards.add(keyboard) + keyboards = list(sorted(keyboards)) + return keyboards + + def keyboard_folder_or_all(keyboard): """Returns the actual keyboard folder. |