aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorQMK Bot <[email protected]>2024-10-30 05:17:31 +0000
committerQMK Bot <[email protected]>2024-10-30 05:17:31 +0000
commit114b3db96afe86086ddaad0318422dc9f429d62f (patch)
treea11d624bf5874dbb14428fb13186f73d5594f089 /lib
parentb8dd09994a53e2fd972aeac05c419399e9ca1651 (diff)
parente6daffce464a0ea288bee68b49f8c7605d464c1b (diff)
downloadqmk_firmware-114b3db96afe86086ddaad0318422dc9f429d62f.tar.gz
qmk_firmware-114b3db96afe86086ddaad0318422dc9f429d62f.zip
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib')
-rw-r--r--lib/python/qmk/decorators.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/lib/python/qmk/decorators.py b/lib/python/qmk/decorators.py
index f6270990b9..16b44d6d59 100644
--- a/lib/python/qmk/decorators.py
+++ b/lib/python/qmk/decorators.py
@@ -9,6 +9,15 @@ from qmk.keyboard import find_keyboard_from_dir
from qmk.keymap import find_keymap_from_dir
+def _get_subcommand_name():
+ """Handle missing cli.subcommand_name on older versions of milc
+ """
+ try:
+ return cli.subcommand_name
+ except AttributeError:
+ return cli._subcommand.__name__
+
+
def automagic_keyboard(func):
"""Sets `cli.config.<subcommand>.keyboard` based on environment.
@@ -16,13 +25,15 @@ def automagic_keyboard(func):
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
+ cmd = _get_subcommand_name()
+
# Ensure that `--keyboard` was not passed and CWD is under `qmk_firmware/keyboards`
- if cli.config_source[cli._subcommand.__name__]['keyboard'] != 'argument':
+ if cli.config_source[cmd]['keyboard'] != 'argument':
keyboard = find_keyboard_from_dir()
if keyboard:
- cli.config[cli._subcommand.__name__]['keyboard'] = keyboard
- cli.config_source[cli._subcommand.__name__]['keyboard'] = 'keyboard_directory'
+ cli.config[cmd]['keyboard'] = keyboard
+ cli.config_source[cmd]['keyboard'] = 'keyboard_directory'
return func(*args, **kwargs)
@@ -36,13 +47,15 @@ def automagic_keymap(func):
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
+ cmd = _get_subcommand_name()
+
# Ensure that `--keymap` was not passed and that we're under `qmk_firmware`
- if cli.config_source[cli._subcommand.__name__]['keymap'] != 'argument':
+ if cli.config_source[cmd]['keymap'] != 'argument':
keymap_name, keymap_type = find_keymap_from_dir()
if keymap_name:
- cli.config[cli._subcommand.__name__]['keymap'] = keymap_name
- cli.config_source[cli._subcommand.__name__]['keymap'] = keymap_type
+ cli.config[cmd]['keymap'] = keymap_name
+ cli.config_source[cmd]['keymap'] = keymap_type
return func(*args, **kwargs)