diff options
Diffstat (limited to 'lib/python/qmk/keyboard.py')
-rw-r--r-- | lib/python/qmk/keyboard.py | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py index fcf5b5b158..254dc62309 100644 --- a/lib/python/qmk/keyboard.py +++ b/lib/python/qmk/keyboard.py @@ -99,8 +99,6 @@ 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) @@ -121,7 +119,7 @@ def find_readme(keyboard): def keyboard_folder(keyboard): """Returns the actual keyboard folder. - This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard. + This checks aliases to resolve the actual path for a keyboard. """ aliases = keyboard_alias_definitions() @@ -131,8 +129,6 @@ def keyboard_folder(keyboard): if keyboard == last_keyboard: break - keyboard = resolve_keyboard(keyboard) - if not qmk.path.is_keyboard(keyboard): raise ValueError(f'Invalid keyboard: {keyboard}') @@ -158,7 +154,7 @@ def keyboard_aliases(keyboard): def keyboard_folder_or_all(keyboard): """Returns the actual keyboard folder. - This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard. + This checks aliases to resolve the actual path for a keyboard. If the supplied argument is "all", it returns an AllKeyboards object. """ if keyboard == 'all': @@ -179,32 +175,18 @@ def keyboard_completer(prefix, action, parser, parsed_args): return list_keyboards() -def list_keyboards(resolve_defaults=True): - """Returns a list of all keyboards - optionally processing any DEFAULT_FOLDER. +def list_keyboards(): + """Returns a list of all keyboards """ # We avoid pathlib here because this is performance critical code. - 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] + kb_wildcard = os.path.join(base_path, "**", 'keyboard.json') + 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: - found = map(resolve_keyboard, found) return sorted(set(found)) -@lru_cache(maxsize=None) -def resolve_keyboard(keyboard): - cur_dir = Path('keyboards') - rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') - while 'DEFAULT_FOLDER' in rules and keyboard != rules['DEFAULT_FOLDER']: - keyboard = rules['DEFAULT_FOLDER'] - rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') - return keyboard - - def config_h(keyboard): """Parses all the config.h files for a keyboard. @@ -216,7 +198,7 @@ def config_h(keyboard): """ config = {} cur_dir = Path('keyboards') - keyboard = Path(resolve_keyboard(keyboard)) + keyboard = Path(keyboard) for dir in keyboard.parts: cur_dir = cur_dir / dir @@ -235,7 +217,7 @@ def rules_mk(keyboard): a dictionary representing the content of the entire rules.mk tree for a keyboard """ cur_dir = Path('keyboards') - keyboard = Path(resolve_keyboard(keyboard)) + keyboard = Path(keyboard) rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk') for i, dir in enumerate(keyboard.parts): |