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.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/python/qmk/cli/list/keyboards.py b/lib/python/qmk/cli/list/keyboards.py
index 2a29ccb14..76e7760e8 100644
--- a/lib/python/qmk/cli/list/keyboards.py
+++ b/lib/python/qmk/cli/list/keyboards.py
@@ -1,27 +1,27 @@
1"""List the keyboards currently defined within QMK 1"""List the keyboards currently defined within QMK
2""" 2"""
3import os 3import os
4import re
5import glob 4import glob
6 5
7from milc import cli 6from milc import cli
8 7
8BASE_PATH = os.path.join(os.getcwd(), "keyboards") + os.path.sep
9KB_WILDCARD = os.path.join(BASE_PATH, "**", "rules.mk")
10
11
12def find_name(path):
13 """Determine the keyboard name by stripping off the base_path and rules.mk.
14 """
15 return path.replace(BASE_PATH, "").replace(os.path.sep + "rules.mk", "")
16
9 17
10@cli.subcommand("List the keyboards currently defined within QMK") 18@cli.subcommand("List the keyboards currently defined within QMK")
11def list_keyboards(cli): 19def list_keyboards(cli):
12 """List the keyboards currently defined within QMK 20 """List the keyboards currently defined within QMK
13 """ 21 """
14
15 base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep
16 kb_path_wildcard = os.path.join(base_path, "**", "rules.mk")
17
18 # find everywhere we have rules.mk where keymaps isn't in the path 22 # find everywhere we have rules.mk where keymaps isn't in the path
19 paths = [path for path in glob.iglob(kb_path_wildcard, recursive=True) if 'keymaps' not in path] 23 paths = [path for path in glob.iglob(KB_WILDCARD, recursive=True) if 'keymaps' not in path]
20
21 # strip the keyboard directory path prefix and rules.mk suffix and alphabetize
22 find_name = lambda path: path.replace(base_path, "").replace(os.path.sep + "rules.mk", "")
23 names = sorted(map(find_name, paths))
24 24
25 for name in names: 25 # Extract the keyboard name from the path and print it
26 # We echo instead of cli.log.info to allow easier piping of this output 26 for keyboard_name in sorted(map(find_name, paths)):
27 cli.echo(name) 27 print(keyboard_name)