aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/keyboard.py
diff options
context:
space:
mode:
authorNick Brassel <[email protected]>2024-05-28 14:39:23 +1000
committerNick Brassel <[email protected]>2024-05-28 14:39:23 +1000
commitf76cc320fd9f3365a80cc0d8af2990bc28d76bde (patch)
tree3c5330bbc9ab254424ac57335510de341b4ada11 /lib/python/qmk/keyboard.py
parent7620c64b99dc5bec480bfaa2708cb3fae709e2b3 (diff)
parent465ab5a20643722c9b712c6b6924472b7345dd64 (diff)
downloadqmk_firmware-f76cc320fd9f3365a80cc0d8af2990bc28d76bde.tar.gz
qmk_firmware-f76cc320fd9f3365a80cc0d8af2990bc28d76bde.zip
Merge branch 'develop'0.25.0
Diffstat (limited to 'lib/python/qmk/keyboard.py')
-rw-r--r--lib/python/qmk/keyboard.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py
index b56505d649..fcf5b5b158 100644
--- a/lib/python/qmk/keyboard.py
+++ b/lib/python/qmk/keyboard.py
@@ -99,6 +99,8 @@ def find_keyboard_from_dir():
keymap_index = len(current_path.parts) - current_path.parts.index('keymaps') - 1
current_path = current_path.parents[keymap_index]
+ current_path = resolve_keyboard(current_path)
+
if qmk.path.is_keyboard(current_path):
return str(current_path)
@@ -166,9 +168,9 @@ def keyboard_folder_or_all(keyboard):
def _find_name(path):
- """Determine the keyboard name by stripping off the base_path and rules.mk.
+ """Determine the keyboard name by stripping off the base_path and filename.
"""
- return path.replace(base_path, "").replace(os.path.sep + "rules.mk", "")
+ return path.replace(base_path, "").rsplit(os.path.sep, 1)[0]
def keyboard_completer(prefix, action, parser, parsed_args):
@@ -181,8 +183,10 @@ def list_keyboards(resolve_defaults=True):
"""Returns a list of all keyboards - optionally processing any DEFAULT_FOLDER.
"""
# We avoid pathlib here because this is performance critical code.
- kb_wildcard = os.path.join(base_path, "**", "rules.mk")
- paths = [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path]
+ paths = []
+ for marker in ['rules.mk', 'keyboard.json']:
+ kb_wildcard = os.path.join(base_path, "**", marker)
+ paths += [path for path in glob(kb_wildcard, recursive=True) if os.path.sep + 'keymaps' + os.path.sep not in path]
found = map(_find_name, paths)
if resolve_defaults: