summaryrefslogtreecommitdiff
path: root/lib/python/qmk
diff options
context:
space:
mode:
authorErovia <erovia@users.noreply.github.com>2019-10-08 21:50:21 +0200
committerFlorian Didron <fdidron@users.noreply.github.com>2020-06-12 17:00:27 +0900
commit1b04d564e296543215c80a8c08f49efd7bb46b43 (patch)
tree6dc18748f8efd0f736e3fa85c2ac6ec2c3f20768 /lib/python/qmk
parent84a7d834ec7709463e53a0e21f465d8f39d4b62f (diff)
CLI: add support for list_keymaps
List all the available keymaps for a given keyboard Add bs4 to requirements.txt UnicodeDammit is needed from bs4 for reading files. Major update to work better with revisions Find the community keymaps supported by each revision. Get all buildable keymaps for each revision The command now return all keymaps that's buildable for a keyboard/revision. If the base directory of a keyboard does not contain a 'rules.mk' file, nothing is returned. If the base directory contains a 'keymaps' directory, those keycaps will be returned for every revision. Fix help message. Try to figure out revision, drop -rv/--revision argument Fix output format Another major refactoring, add documentation Move all useful functions to the qmk module and use the cli subcommand as a wrapper around it. Add both inline comments and documentation. Add test for list_keymaps Fix regex for parsing rules.mk files I don't know why it couldn't put it together before... ¯\_(ツ)_/¯ Drop bs4 dependency, update docs, minor improvements Return only the unique keymaps Fix merging community and base keymaps Major rework, no regex/globbing, more walking Instead of using regexes and globbing to find the rules.mk and keymap.c files, walk the directory tree to find them. Also, do away with the concept of revision. Fix commandline parsing and flake8 findings, rebase Fixed commandline and config parsing. Thx @xplusplus. Rebased on master and fixed merge conflicts. Code cleanup, use pathlib, use pytest keyboard Clean up checks and logics that are unnecessary due to MILC updates. Use pathlib instead of os.path for readability. Use the 'pytest' keyboard for the tests. Add community layout for 'handwired/onekey/pytest' so we can test community layouts. Pathlib-ify qmk.keymap.list_keymaps() fix list_keymaps for python 3.5
Diffstat (limited to 'lib/python/qmk')
-rw-r--r--lib/python/qmk/path.py43
1 files changed, 1 insertions, 42 deletions
diff --git a/lib/python/qmk/path.py b/lib/python/qmk/path.py
index bfaa439249..64b2dc8350 100644
--- a/lib/python/qmk/path.py
+++ b/lib/python/qmk/path.py
@@ -8,35 +8,6 @@ from qmk.constants import QMK_FIRMWARE, MAX_KEYBOARD_SUBFOLDERS
from qmk.errors import NoSuchKeyboardError
-def is_keymap_dir(keymap_path):
- """Returns True if `keymap_path` is a valid keymap directory.
- """
- keymap_path = Path(keymap_path)
- keymap_c = keymap_path / 'keymap.c'
- keymap_json = keymap_path / 'keymap.json'
-
- return any((keymap_c.exists(), keymap_json.exists()))
-
-
-def is_keyboard(keyboard_name):
- """Returns True if `keyboard_name` is a keyboard we can compile.
- """
- keyboard_path = QMK_FIRMWARE / 'keyboards' / keyboard_name
- rules_mk = keyboard_path / 'rules.mk'
- return rules_mk.exists()
-
-
-def under_qmk_firmware():
- """Returns a Path object representing the relative path under qmk_firmware, or None.
- """
- cwd = Path(os.environ['ORIG_CWD'])
-
- try:
- return cwd.relative_to(QMK_FIRMWARE)
- except ValueError:
- return None
-
-
def keymap(keyboard):
"""Locate the correct directory for storing a keymap.
@@ -69,16 +40,4 @@ def normpath(path):
return Path(os.environ['ORIG_CWD']) / path
-
-def c_source_files(dir_names):
- """Returns a list of all *.c, *.h, and *.cpp files for a given list of directories
-
- Args:
-
- dir_names
- List of directories, relative pathing starts at qmk's cwd
- """
- files = []
- for dir in dir_names:
- files.extend(file for file in Path(dir).glob('**/*') if file.suffix in ['.c', '.h', '.cpp'])
- return files
+ return os.path.normpath(os.path.join(os.environ['ORIG_CWD'], path))