aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/handwired/onekey/rules.mk1
-rw-r--r--layouts/community/ortho_1x1/layout.json1
-rw-r--r--layouts/community/ortho_1x1/test/keymap.c12
-rw-r--r--lib/python/qmk/cli/list/keymaps.py10
-rw-r--r--lib/python/qmk/makefile.py21
-rw-r--r--lib/python/qmk/path.py13
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py4
7 files changed, 30 insertions, 32 deletions
diff --git a/keyboards/handwired/onekey/rules.mk b/keyboards/handwired/onekey/rules.mk
index 245f9025d..8ed255768 100644
--- a/keyboards/handwired/onekey/rules.mk
+++ b/keyboards/handwired/onekey/rules.mk
@@ -20,3 +20,4 @@ FAUXCLICKY_ENABLE = no # Use buzzer to emulate clicky switches
20HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400) 20HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
21 21
22DEFAULT_FOLDER = handwired/onekey/promicro 22DEFAULT_FOLDER = handwired/onekey/promicro
23LAYOUTS = ortho_1x1
diff --git a/layouts/community/ortho_1x1/layout.json b/layouts/community/ortho_1x1/layout.json
new file mode 100644
index 000000000..66a1e1856
--- /dev/null
+++ b/layouts/community/ortho_1x1/layout.json
@@ -0,0 +1 @@
[""]
diff --git a/layouts/community/ortho_1x1/test/keymap.c b/layouts/community/ortho_1x1/test/keymap.c
new file mode 100644
index 000000000..6a186669b
--- /dev/null
+++ b/layouts/community/ortho_1x1/test/keymap.c
@@ -0,0 +1,12 @@
1#include QMK_KEYBOARD_H
2
3/* This keyboard/layout is used to test community layout discovery/compilation. */
4
5#define _DEFAULT 0
6
7const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
8
9[_DEFAULT] = LAYOUT (
10 KC_B
11),
12};
diff --git a/lib/python/qmk/cli/list/keymaps.py b/lib/python/qmk/cli/list/keymaps.py
index aab973140..d199d29bc 100644
--- a/lib/python/qmk/cli/list/keymaps.py
+++ b/lib/python/qmk/cli/list/keymaps.py
@@ -10,17 +10,13 @@ from qmk.errors import NoSuchKeyboardError
10def list_keymaps(cli): 10def list_keymaps(cli):
11 """List the keymaps for a specific keyboard 11 """List the keymaps for a specific keyboard
12 """ 12 """
13 # ask for user input if keyboard was not provided in the command line
14 if cli.args.keyboard:
15 cli.config.list_keymaps.keyboard = cli.args.keyboard
16 elif not cli.config.list_keymaps.keyboard:
17 cli.config.list_keymaps.keyboard = input("Keyboard Name: ")
18
19 try: 13 try:
20 for name in qmk.keymap.list_keymaps(cli.config.list_keymaps.keyboard): 14 for name in qmk.keymap.list_keymaps(cli.config.list_keymaps.keyboard):
21 # We echo instead of cli.log.info to allow easier piping of this output 15 # We echo instead of cli.log.info to allow easier piping of this output
22 cli.echo('%s:%s', cli.config.list_keymaps.keyboard, name) 16 cli.echo('%s', name)
23 except NoSuchKeyboardError as e: 17 except NoSuchKeyboardError as e:
24 cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e.message) 18 cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e.message)
25 except (FileNotFoundError, PermissionError) as e: 19 except (FileNotFoundError, PermissionError) as e:
26 cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e) 20 cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e)
21 except TypeError:
22 cli.echo("{fg_red}Something went wrong. Did you specify a keyboard?")
diff --git a/lib/python/qmk/makefile.py b/lib/python/qmk/makefile.py
index 89494bbc0..8645056d2 100644
--- a/lib/python/qmk/makefile.py
+++ b/lib/python/qmk/makefile.py
@@ -1,8 +1,7 @@
1""" Functions for working with Makefiles 1""" Functions for working with Makefiles
2""" 2"""
3import os 3from pathlib import Path
4 4
5import qmk.path
6from qmk.errors import NoSuchKeyboardError 5from qmk.errors import NoSuchKeyboardError
7 6
8 7
@@ -19,8 +18,9 @@ def parse_rules_mk_file(file, rules_mk=None):
19 if not rules_mk: 18 if not rules_mk:
20 rules_mk = {} 19 rules_mk = {}
21 20
22 if os.path.exists(file): 21 file = Path(file)
23 rules_mk_lines = qmk.path.file_lines(file) 22 if file.exists():
23 rules_mk_lines = file.read_text().split("\n")
24 24
25 for line in rules_mk_lines: 25 for line in rules_mk_lines:
26 # Filter out comments 26 # Filter out comments
@@ -66,15 +66,16 @@ def get_rules_mk(keyboard):
66 a dictionary with the content of the rules.mk file 66 a dictionary with the content of the rules.mk file
67 """ 67 """
68 # Start with qmk_firmware/keyboards 68 # Start with qmk_firmware/keyboards
69 kb_path = os.path.join(os.getcwd(), "keyboards") 69 kb_path = Path.cwd() / "keyboards"
70 # walk down the directory tree 70 # walk down the directory tree
71 # and collect all rules.mk files 71 # and collect all rules.mk files
72 if os.path.exists(os.path.join(kb_path, keyboard)): 72 kb_dir = kb_path / keyboard
73 if kb_dir.exists():
73 rules_mk = dict() 74 rules_mk = dict()
74 for directory in keyboard.split(os.path.sep): 75 for directory in Path(keyboard).parts:
75 kb_path = os.path.join(kb_path, directory) 76 kb_path = kb_path / directory
76 rules_mk_path = os.path.join(kb_path, "rules.mk") 77 rules_mk_path = kb_path / "rules.mk"
77 if os.path.exists(rules_mk_path): 78 if rules_mk_path.exists():
78 rules_mk = parse_rules_mk_file(rules_mk_path, rules_mk) 79 rules_mk = parse_rules_mk_file(rules_mk_path, rules_mk)
79 else: 80 else:
80 raise NoSuchKeyboardError("The requested keyboard and/or revision does not exist.") 81 raise NoSuchKeyboardError("The requested keyboard and/or revision does not exist.")
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py
index bb28049b9..cf087265f 100644
--- a/lib/python/qmk/path.py
+++ b/lib/python/qmk/path.py
@@ -33,16 +33,3 @@ def normpath(path):
33 return os.path.normpath(path) 33 return os.path.normpath(path)
34 34
35 return os.path.normpath(os.path.join(os.environ['ORIG_CWD'], path)) 35 return os.path.normpath(os.path.join(os.environ['ORIG_CWD'], path))
36
37
38def file_lines(filename):
39 """ Return a files content, line by line
40
41 Args:
42 filename: path to the file
43
44 Returns:
45 an list, in which each item is a line of the file
46 """
47 with open(filename, "r") as fd:
48 return fd.readlines()
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index d88437903..bb77952fa 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -57,9 +57,9 @@ def test_list_keyboards():
57 57
58 58
59def test_list_keymaps(): 59def test_list_keymaps():
60 result = check_subcommand("list-keymaps", "-kb", "planck/ez") 60 result = check_subcommand("list-keymaps", "-kb", "handwired/onekey/pytest")
61 assert result.returncode == 0 61 assert result.returncode == 0
62 assert "planck/ez:default" and "planck/ez:drashna" in result.stdout 62 assert "default" and "test" in result.stdout
63 63
64 64
65def test_list_keymaps_no_keyboard_found(): 65def test_list_keymaps_no_keyboard_found():