Fix commandline parsing and flake8 findings, rebase
Fixed commandline and config parsing. Thx @xplusplus. Rebased on master and fixed merge conflicts.
This commit is contained in:
parent
988bfffca2
commit
8eeab1112a
@ -4,13 +4,16 @@ from milc import cli
|
|||||||
import qmk.keymap
|
import qmk.keymap
|
||||||
from qmk.errors import NoSuchKeyboardError
|
from qmk.errors import NoSuchKeyboardError
|
||||||
|
|
||||||
|
|
||||||
@cli.argument("-kb", "--keyboard", help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
|
@cli.argument("-kb", "--keyboard", help="Specify keyboard name. Example: 1upkeyboards/1up60hse")
|
||||||
@cli.subcommand("List the keymaps for a specific keyboard")
|
@cli.subcommand("List the keymaps for a specific keyboard")
|
||||||
def list_keymaps(cli):
|
def list_keymaps(cli):
|
||||||
"""List the keymaps for a specific keyboard
|
"""List the keymaps for a specific keyboard
|
||||||
"""
|
"""
|
||||||
# ask for user input if keyboard was not provided in the command line
|
# 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: ")
|
cli.config.list_keymaps.keyboard = input("Keyboard Name: ")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
"""Functions that help you work with QMK keymaps.
|
"""Functions that help you work with QMK keymaps.
|
||||||
"""
|
"""
|
||||||
import os
|
import os
|
||||||
from traceback import format_exc
|
|
||||||
|
|
||||||
import qmk.path
|
import qmk.path
|
||||||
import qmk.makefile
|
import qmk.makefile
|
||||||
from qmk.errors import NoSuchKeyboardError
|
|
||||||
|
|
||||||
# The `keymap.c` template to use when a keyboard doesn't have its own
|
# The `keymap.c` template to use when a keyboard doesn't have its own
|
||||||
DEFAULT_KEYMAP_C = """#include QMK_KEYBOARD_H
|
DEFAULT_KEYMAP_C = """#include QMK_KEYBOARD_H
|
||||||
@ -98,6 +96,7 @@ def write(keyboard, keymap, layout, layers):
|
|||||||
|
|
||||||
return keymap_file
|
return keymap_file
|
||||||
|
|
||||||
|
|
||||||
def list_keymaps(keyboard_name):
|
def list_keymaps(keyboard_name):
|
||||||
""" List the available keymaps for a keyboard.
|
""" List the available keymaps for a keyboard.
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import os
|
|||||||
import qmk.path
|
import qmk.path
|
||||||
from qmk.errors import NoSuchKeyboardError
|
from qmk.errors import NoSuchKeyboardError
|
||||||
|
|
||||||
|
|
||||||
def parse_rules_mk_file(file, rules_mk=None):
|
def parse_rules_mk_file(file, rules_mk=None):
|
||||||
"""Turn a rules.mk file into a dictionary.
|
"""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()
|
rules_mk[key.strip()] = value.strip()
|
||||||
else:
|
else:
|
||||||
if ":=" in line:
|
if ":=" in line:
|
||||||
line.replace(":","")
|
line.replace(":", "")
|
||||||
key, value = line.split('=', 1)
|
key, value = line.split('=', 1)
|
||||||
rules_mk[key.strip()] = value.strip()
|
rules_mk[key.strip()] = value.strip()
|
||||||
|
|
||||||
return rules_mk
|
return rules_mk
|
||||||
|
|
||||||
|
|
||||||
def get_rules_mk(keyboard):
|
def get_rules_mk(keyboard):
|
||||||
""" Get a rules.mk for a keyboard
|
""" Get a rules.mk for a keyboard
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ import os
|
|||||||
|
|
||||||
from qmk.errors import NoSuchKeyboardError
|
from qmk.errors import NoSuchKeyboardError
|
||||||
|
|
||||||
|
|
||||||
def keymap(keyboard):
|
def keymap(keyboard):
|
||||||
"""Locate the correct directory for storing a keymap.
|
"""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))
|
return os.path.normpath(os.path.join(os.environ['ORIG_CWD'], path))
|
||||||
|
|
||||||
|
|
||||||
def file_lines(filename):
|
def file_lines(filename):
|
||||||
""" Return a files content, line by line
|
""" Return a files content, line by line
|
||||||
|
|
||||||
|
@ -55,7 +55,14 @@ def test_list_keyboards():
|
|||||||
# this will fail if handwired/onekey/pytest is removed
|
# this will fail if handwired/onekey/pytest is removed
|
||||||
assert 'handwired/onekey/pytest' in result.stdout
|
assert 'handwired/onekey/pytest' in result.stdout
|
||||||
|
|
||||||
|
|
||||||
def test_list_keymaps():
|
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 result.returncode == 0
|
||||||
assert "planck/ez:default" and "planck/ez:drashna" in result.stdout
|
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
|
||||||
|
Loading…
Reference in New Issue
Block a user