Browse Source

Fix commandline parsing and flake8 findings, rebase

Fixed commandline and config parsing. Thx @xplusplus.
Rebased on master and fixed merge conflicts.
pull/8180/head
Erovia 4 years ago
committed by skullydazed
parent
commit
8eeab1112a
5 changed files with 18 additions and 5 deletions
  1. +4
    -1
      lib/python/qmk/cli/list/keymaps.py
  2. +1
    -2
      lib/python/qmk/keymap.py
  3. +3
    -1
      lib/python/qmk/makefile.py
  4. +2
    -0
      lib/python/qmk/path.py
  5. +8
    -1
      lib/python/qmk/tests/test_cli_commands.py

+ 4
- 1
lib/python/qmk/cli/list/keymaps.py View File

@ -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:


+ 1
- 2
lib/python/qmk/keymap.py View File

@ -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.


+ 3
- 1
lib/python/qmk/makefile.py View File

@ -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


+ 2
- 0
lib/python/qmk/path.py View File

@ -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


+ 8
- 1
lib/python/qmk/tests/test_cli_commands.py View File

@ -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

Loading…
Cancel
Save