summaryrefslogtreecommitdiff
path: root/lib/python/qmk/commands.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/qmk/commands.py')
-rw-r--r--lib/python/qmk/commands.py69
1 files changed, 0 insertions, 69 deletions
diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py
index f6596eb719..2727c9d22e 100644
--- a/lib/python/qmk/commands.py
+++ b/lib/python/qmk/commands.py
@@ -1,12 +1,8 @@
"""Helper functions for commands.
"""
import json
-from pathlib import Path
-
-from milc import cli
import qmk.keymap
-from qmk.path import is_keyboard, is_keymap_dir, under_qmk_firmware
def create_make_command(keyboard, keymap, target=None):
@@ -62,71 +58,6 @@ def compile_configurator_json(configurator_filename, bootloader=None):
return create_make_command(user_keymap['keyboard'], user_keymap['keymap'], bootloader)
-def find_keyboard_keymap():
- """Returns `(keyboard_name, keymap_name)` based on the user's current environment.
-
- This determines the keyboard and keymap name using the following precedence order:
-
- * Command line flags (--keyboard and --keymap)
- * Current working directory
- * `keyboards/<keyboard_name>`
- * `keyboards/<keyboard_name>/keymaps/<keymap_name>`
- * `layouts/**/<keymap_name>`
- * `users/<keymap_name>`
- * Configuration
- * cli.config.<subcommand>.keyboard
- * cli.config.<subcommand>.keymap
- """
- # Check to make sure their copy of MILC supports config_source
- if not hasattr(cli, 'config_source'):
- cli.log.error("Your QMK CLI is out of date. Please upgrade using pip3 or your package manager.")
- exit(1)
-
- # State variables
- relative_cwd = under_qmk_firmware()
- keyboard_name = ""
- keymap_name = ""
-
- # If the keyboard or keymap are passed as arguments use that in preference to anything else
- if cli.config_source[cli._entrypoint.__name__]['keyboard'] == 'argument':
- keyboard_name = cli.config[cli._entrypoint.__name__]['keyboard']
- if cli.config_source[cli._entrypoint.__name__]['keymap'] == 'argument':
- keymap_name = cli.config[cli._entrypoint.__name__]['keymap']
-
- if not keyboard_name or not keymap_name:
- # If we don't have a keyboard_name and keymap_name from arguments try to derive one or both
- if relative_cwd and relative_cwd.parts and relative_cwd.parts[0] == 'keyboards':
- # Try to determine the keyboard and/or keymap name
- current_path = Path('/'.join(relative_cwd.parts[1:]))
-
- if current_path.parts[-2] == 'keymaps':
- if not keymap_name:
- keymap_name = current_path.parts[-1]
- if not keyboard_name:
- keyboard_name = '/'.join(current_path.parts[:-2])
- elif not keyboard_name and is_keyboard(current_path):
- keyboard_name = str(current_path)
-
- elif relative_cwd and relative_cwd.parts and relative_cwd.parts[0] == 'layouts':
- # Try to determine the keymap name from the community layout
- if is_keymap_dir(relative_cwd) and not keymap_name:
- keymap_name = relative_cwd.name
-
- elif relative_cwd and relative_cwd.parts and relative_cwd.parts[0] == 'users':
- # Try to determine the keymap name based on which userspace they're in
- if not keymap_name and len(relative_cwd.parts) > 1:
- keymap_name = relative_cwd.parts[1]
-
- # If we still don't have a keyboard and keymap check the config
- if not keyboard_name and cli.config[cli._entrypoint.__name__]['keyboard']:
- keyboard_name = cli.config[cli._entrypoint.__name__]['keyboard']
-
- if not keymap_name and cli.config[cli._entrypoint.__name__]['keymap']:
- keymap_name = cli.config[cli._entrypoint.__name__]['keymap']
-
- return (keyboard_name, keymap_name)
-
-
def parse_configurator_json(configurator_file):
"""Open and parse a configurator json export
"""