diff options
author | QMK Bot <hello@qmk.fm> | 2023-09-22 02:12:53 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2023-09-22 02:12:53 +0000 |
commit | 8ea8b80b85f4de058194e17e2daafdc1fa0c906c (patch) | |
tree | de23ebc7115dac11834bfdc57f2d083692b4d96c /lib/python/qmk/keyboard.py | |
parent | adc217137ed7e8a769492e21d6c67a89122fb9db (diff) | |
parent | abd432fd7afa556e2d1df1c191050800068e6ec7 (diff) |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/keyboard.py')
-rw-r--r-- | lib/python/qmk/keyboard.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/python/qmk/keyboard.py b/lib/python/qmk/keyboard.py index 235b62640c..3e5cae4b22 100644 --- a/lib/python/qmk/keyboard.py +++ b/lib/python/qmk/keyboard.py @@ -30,9 +30,29 @@ BOX_DRAWING_CHARACTERS = { }, } + +class AllKeyboards: + """Represents all keyboards. + """ + def __str__(self): + return 'all' + + def __repr__(self): + return 'all' + + def __eq__(self, other): + return isinstance(other, AllKeyboards) + + base_path = os.path.join(os.getcwd(), "keyboards") + os.path.sep +def is_all_keyboards(keyboard): + """Returns True if the keyboard is an AllKeyboards object. + """ + return isinstance(keyboard, AllKeyboards) + + def find_keyboard_from_dir(): """Returns a keyboard name based on the user's current directory. """ @@ -86,6 +106,18 @@ def keyboard_folder(keyboard): return keyboard +def keyboard_folder_or_all(keyboard): + """Returns the actual keyboard folder. + + This checks aliases and DEFAULT_FOLDER to resolve the actual path for a keyboard. + If the supplied argument is "all", it returns an AllKeyboards object. + """ + if keyboard == 'all': + return AllKeyboards() + + return keyboard_folder(keyboard) + + def _find_name(path): """Determine the keyboard name by stripping off the base_path and rules.mk. """ |