summaryrefslogtreecommitdiff
path: root/lib/python
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python')
-rw-r--r--lib/python/qmk/cli/list/keymaps.py5
-rw-r--r--lib/python/qmk/keymap.py3
-rw-r--r--lib/python/qmk/makefile.py4
-rw-r--r--lib/python/qmk/path.py2
-rw-r--r--lib/python/qmk/tests/test_cli_commands.py9
5 files changed, 18 insertions, 5 deletions
diff --git a/lib/python/qmk/cli/list/keymaps.py b/lib/python/qmk/cli/list/keymaps.py
index a17c6a9130..aab9731405 100644
--- a/lib/python/qmk/cli/list/keymaps.py
+++ b/lib/python/qmk/cli/list/keymaps.py
@@ -4,13 +4,16 @@ from milc import cli
import qmk.keymap
from qmk.errors import NoSuchKeyboardError
+
@cli.argument("-kb", "--keyboard", help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
@cli.subcommand("List the keymaps for a specific keyboard")
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 not cli.config.list_keymaps.keyboard:
+ 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:
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py
index 113b885de3..afb001f3e0 100644
--- a/lib/python/qmk/keymap.py
+++ b/lib/python/qmk/keymap.py
@@ -1,11 +1,9 @@
"""Functions that help you work with QMK keymaps.
"""
import os
-from traceback import format_exc
import qmk.path
import qmk.makefile
-from qmk.errors import NoSuchKeyboardError
# The `keymap.c` template to use when a keyboard doesn't have its own
DEFAULT_KEYMAP_C = """#include QMK_KEYBOARD_H
@@ -98,6 +96,7 @@ def write(keyboard, keymap, layout, layers):
return keymap_file
+
def list_keymaps(keyboard_name):
""" List the available keymaps for a keyboard.
diff --git a/lib/python/qmk/makefile.py b/lib/python/qmk/makefile.py
index c53f12ac75..89494bbc02 100644
--- a/lib/python/qmk/makefile.py
+++ b/lib/python/qmk/makefile.py
@@ -5,6 +5,7 @@ import os
import qmk.path
from qmk.errors import NoSuchKeyboardError
+
def parse_rules_mk_file(file, rules_mk=None):
"""Turn a rules.mk file into a dictionary.
@@ -45,12 +46,13 @@ def parse_rules_mk_file(file, rules_mk=None):
rules_mk[key.strip()] = value.strip()
else:
if ":=" in line:
- line.replace(":","")
+ line.replace(":", "")
key, value = line.split('=', 1)
rules_mk[key.strip()] = value.strip()
return rules_mk
+
def get_rules_mk(keyboard):
""" Get a rules.mk for a keyboard
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py
index 0cdfe353c5..bb28049b9d 100644
--- a/lib/python/qmk/path.py
+++ b/lib/python/qmk/path.py
@@ -5,6 +5,7 @@ import os
from qmk.errors import NoSuchKeyboardError
+
def keymap(keyboard):
"""Locate the correct directory for storing a keymap.
@@ -33,6 +34,7 @@ def 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
diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py
index 7dc51d2470..d884379035 100644
--- a/lib/python/qmk/tests/test_cli_commands.py
+++ b/lib/python/qmk/tests/test_cli_commands.py
@@ -55,7 +55,14 @@ def test_list_keyboards():
# this will fail if handwired/onekey/pytest is removed
assert 'handwired/onekey/pytest' in result.stdout
+
def test_list_keymaps():
- result = check_subcommand("list_keymaps", "-kb", "planck/ez")
+ result = check_subcommand("list-keymaps", "-kb", "planck/ez")
assert result.returncode == 0
assert "planck/ez:default" and "planck/ez:drashna" in result.stdout
+
+
+def test_list_keymaps_no_keyboard_found():
+ result = check_subcommand("list-keymaps", "-kb", "asdfghjkl")
+ assert result.returncode == 0
+ assert "does not exist" in result.stdout