aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/keyboard.py
diff options
context:
space:
mode:
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: