diff options
author | Zach White <skullydazed@gmail.com> | 2020-10-25 14:48:44 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-25 14:48:44 -0700 |
commit | 0c42f91f4ccf98a37f055afb777ed491da56335e (patch) | |
tree | 547344d80fe7bf75ff3f348eefbc19dbdd346a8a /lib/python/qmk/keyboard.py | |
parent | 8ef82c466e73e555fd74107d4c57e678d7152ecc (diff) | |
download | qmk_firmware-0c42f91f4ccf98a37f055afb777ed491da56335e.tar.gz qmk_firmware-0c42f91f4ccf98a37f055afb777ed491da56335e.zip |
Generate api data on each push (#10609)
* add new qmk generate-api command, to generate a complete set of API data.
* Generate api data and push it to the keyboard repo
* fix typo
* Apply suggestions from code review
Co-authored-by: Joel Challis <git@zvecr.com>
* fixup api workflow
* remove file-changes-action
* use a more mainstream github action
* fix yaml error
* Apply suggestions from code review
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
* more uniform date handling
* make flake8 happy
* Update lib/python/qmk/decorators.py
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Co-authored-by: Joel Challis <git@zvecr.com>
Co-authored-by: Erovia <Erovia@users.noreply.github.com>
Diffstat (limited to 'lib/python/qmk/keyboard.py')
-rw-r--r-- | lib/python/qmk/keyboard.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py index d1f2a301df..9ebb2d77d3 100644 --- a/lib/python/qmk/keyboard.py +++ b/lib/python/qmk/keyboard.py @@ -3,10 +3,30 @@ from array import array from math import ceil from pathlib import Path +import os +from glob import glob from qmk.c_parse import parse_config_h_file from qmk.makefile import parse_rules_mk_file +base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep + + +def _find_name(path): + """Determine the keyboard name by stripping off the base_path and rules.mk. + """ + return path.replace(base_path, "").replace(os.path.sep + "rules.mk", "") + + +def list_keyboards(): + """Returns a list of all keyboards. + """ + # We avoid pathlib here because this is performance critical code. + kb_wildcard = os.path.join(base_path, "**", "rules.mk") + paths = [path for path in glob(kb_wildcard, recursive=True) if 'keymaps' not in path] + + return sorted(map(_find_name, paths)) + def config_h(keyboard): """Parses all the config.h files for a keyboard. |