aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk/cli/list/keyboards.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/cli/list/keyboards.py')
-rw-r--r--lib/python/qmk/cli/list/keyboards.py19
1 files changed, 2 insertions, 17 deletions
diff --git a/lib/python/qmk/cli/list/keyboards.py b/lib/python/qmk/cli/list/keyboards.py
index ca0c5661a..8b6c45167 100644
--- a/lib/python/qmk/cli/list/keyboards.py
+++ b/lib/python/qmk/cli/list/keyboards.py
@@ -1,28 +1,13 @@
1"""List the keyboards currently defined within QMK 1"""List the keyboards currently defined within QMK
2""" 2"""
3# We avoid pathlib here because this is performance critical code.
4import os
5import glob
6
7from milc import cli 3from milc import cli
8 4
9BASE_PATH = os.path.join(os.getcwd(), "keyboards") + os.path.sep 5import qmk.keyboard
10KB_WILDCARD = os.path.join(BASE_PATH, "**", "rules.mk")
11
12
13def find_name(path):
14 """Determine the keyboard name by stripping off the base_path and rules.mk.
15 """
16 return path.replace(BASE_PATH, "").replace(os.path.sep + "rules.mk", "")
17 6
18 7
19@cli.subcommand("List the keyboards currently defined within QMK") 8@cli.subcommand("List the keyboards currently defined within QMK")
20def list_keyboards(cli): 9def list_keyboards(cli):
21 """List the keyboards currently defined within QMK 10 """List the keyboards currently defined within QMK
22 """ 11 """
23 # find everywhere we have rules.mk where keymaps isn't in the path 12 for keyboard_name in qmk.keyboard.list_keyboards():
24 paths = [path for path in glob.iglob(KB_WILDCARD, recursive=True) if 'keymaps' not in path]
25
26 # Extract the keyboard name from the path and print it
27 for keyboard_name in sorted(map(find_name, paths)):
28 print(keyboard_name) 13 print(keyboard_name)