summaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2021-04-25 11:15:54 +1000
committerGitHub <noreply@github.com>2021-04-25 11:15:54 +1000
commitb88498ba85aaf2fdd955ee9cbae6cffb327497de (patch)
tree3736eead42467f32b31bd84a601b84b75858c033 /lib/python
parent0c50a9eae9a7e1773130686b60237ad9e899cd14 (diff)
Fix CLI incorrectly following `DEFAULT_FOLDER` (#12529)
* Attempt to sort out incorrectly following DEFAULT_FOLDER. * Fix CI checks. * qmk pyformat
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/qmk/keyboard.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py
index 0168d17ef3..e457685567 100644
--- a/lib/python/qmk/keyboard.py
+++ b/lib/python/qmk/keyboard.py
@@ -92,7 +92,16 @@ def list_keyboards():
kb_wildcard = os.path.join(base_path, "**", "rules.mk")
paths = [path for path in glob(kb_wildcard, recursive=True) if 'keymaps' not in path]
- return sorted(map(_find_name, paths))
+ return sorted(set(map(resolve_keyboard, map(_find_name, paths))))
+
+
+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):
@@ -106,8 +115,7 @@ def config_h(keyboard):
"""
config = {}
cur_dir = Path('keyboards')
- rules = rules_mk(keyboard)
- keyboard = Path(rules['DEFAULT_FOLDER'] if 'DEFAULT_FOLDER' in rules else keyboard)
+ keyboard = Path(resolve_keyboard(keyboard))
for dir in keyboard.parts:
cur_dir = cur_dir / dir
@@ -125,13 +133,10 @@ def rules_mk(keyboard):
Returns:
a dictionary representing the content of the entire rules.mk tree for a keyboard
"""
- keyboard = Path(keyboard)
cur_dir = Path('keyboards')
+ keyboard = Path(resolve_keyboard(keyboard))
rules = parse_rules_mk_file(cur_dir / keyboard / 'rules.mk')
- if 'DEFAULT_FOLDER' in rules:
- keyboard = Path(rules['DEFAULT_FOLDER'])
-
for i, dir in enumerate(keyboard.parts):
cur_dir = cur_dir / dir
rules = parse_rules_mk_file(cur_dir / 'rules.mk', rules)