aboutsummaryrefslogtreecommitdiffstats
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
HD44780_ENABLE = no # Enable support for HD44780 based LCDs (+400)
DEFAULT_FOLDER = handwired/onekey/promicro
+LAYOUTS = 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 @@
+#include QMK_KEYBOARD_H
+
+/* This keyboard/layout is used to test community layout discovery/compilation. */
+
+#define _DEFAULT 0
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+[_DEFAULT] = LAYOUT (
+ KC_B
+),
+};
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
def list_keymaps(cli):
"""List the keymaps for a specific keyboard
"""
- # ask for user input if keyboard was not provided in the command line
- if cli.args.keyboard:
- cli.config.list_keymaps.keyboard = cli.args.keyboard
- elif not cli.config.list_keymaps.keyboard:
- cli.config.list_keymaps.keyboard = input("Keyboard Name: ")
-
try:
for name in qmk.keymap.list_keymaps(cli.config.list_keymaps.keyboard):
# We echo instead of cli.log.info to allow easier piping of this output
- cli.echo('%s:%s', cli.config.list_keymaps.keyboard, name)
+ cli.echo('%s', name)
except NoSuchKeyboardError as e:
cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e.message)
except (FileNotFoundError, PermissionError) as e:
cli.echo("{fg_red}%s: %s", cli.config.list_keymaps.keyboard, e)
+ except TypeError:
+ 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 @@
""" Functions for working with Makefiles
"""
-import os
+from pathlib import Path
-import qmk.path
from qmk.errors import NoSuchKeyboardError
@@ -19,8 +18,9 @@ def parse_rules_mk_file(file, rules_mk=None):
if not rules_mk:
rules_mk = {}
- if os.path.exists(file):
- rules_mk_lines = qmk.path.file_lines(file)
+ file = Path(file)
+ if file.exists():
+ rules_mk_lines = file.read_text().split("\n")
for line in rules_mk_lines:
# Filter out comments
@@ -66,15 +66,16 @@ def get_rules_mk(keyboard):
a dictionary with the content of the rules.mk file
"""
# Start with qmk_firmware/keyboards
- kb_path = os.path.join(os.getcwd(), "keyboards")
+ kb_path = Path.cwd() / "keyboards"
# walk down the directory tree
# and collect all rules.mk files
- if os.path.exists(os.path.join(kb_path, keyboard)):
+ kb_dir = kb_path / keyboard
+ if kb_dir.exists():
rules_mk = dict()
- for directory in keyboard.split(os.path.sep):
- kb_path = os.path.join(kb_path, directory)
- rules_mk_path = os.path.join(kb_path, "rules.mk")
- if os.path.exists(rules_mk_path):
+ for directory in Path(keyboard).parts:
+ kb_path = kb_path / directory
+ rules_mk_path = kb_path / "rules.mk"
+ if rules_mk_path.exists():
rules_mk = parse_rules_mk_file(rules_mk_path, rules_mk)
else:
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):
return os.path.normpath(path)
return os.path.normpath(os.path.join(os.environ['ORIG_CWD'], path))
-
-
-def file_lines(filename):
- """ Return a files content, line by line
-
- Args:
- filename: path to the file
-
- Returns:
- an list, in which each item is a line of the file
- """
- with open(filename, "r") as fd:
- 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():
def test_list_keymaps():
- result = check_subcommand("list-keymaps", "-kb", "planck/ez")
+ result = check_subcommand("list-keymaps", "-kb", "handwired/onekey/pytest")
assert result.returncode == 0
- assert "planck/ez:default" and "planck/ez:drashna" in result.stdout
+ assert "default" and "test" in result.stdout
def test_list_keymaps_no_keyboard_found():