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.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py
index d1f2a301d..9ebb2d77d 100644
--- a/lib/python/qmk/keyboard.py
+++ b/lib/python/qmk/keyboard.py
@@ -3,10 +3,30 @@
3from array import array 3from array import array
4from math import ceil 4from math import ceil
5from pathlib import Path 5from pathlib import Path
6import os
7from glob import glob
6 8
7from qmk.c_parse import parse_config_h_file 9from qmk.c_parse import parse_config_h_file
8from qmk.makefile import parse_rules_mk_file 10from qmk.makefile import parse_rules_mk_file
9 11
12base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep
13
14
15def _find_name(path):
16 """Determine the keyboard name by stripping off the base_path and rules.mk.
17 """
18 return path.replace(base_path, "").replace(os.path.sep + "rules.mk", "")
19
20
21def list_keyboards():
22 """Returns a list of all keyboards.
23 """
24 # We avoid pathlib here because this is performance critical code.
25 kb_wildcard = os.path.join(base_path, "**", "rules.mk")
26 paths = [path for path in glob(kb_wildcard, recursive=True) if 'keymaps' not in path]
27
28 return sorted(map(_find_name, paths))
29
10 30
11def config_h(keyboard): 31def config_h(keyboard):
12 """Parses all the config.h files for a keyboard. 32 """Parses all the config.h files for a keyboard.