diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/python/qmk/keymap.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index afb001f3e..721a0deca 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | """Functions that help you work with QMK keymaps. | 1 | """Functions that help you work with QMK keymaps. |
| 2 | """ | 2 | """ |
| 3 | import os | 3 | import os |
| 4 | from pathlib import Path | ||
| 4 | 5 | ||
| 5 | import qmk.path | 6 | import qmk.path |
| 6 | import qmk.makefile | 7 | import qmk.makefile |
| @@ -112,22 +113,22 @@ def list_keymaps(keyboard_name): | |||
| 112 | 113 | ||
| 113 | if rules_mk: | 114 | if rules_mk: |
| 114 | # qmk_firmware/keyboards | 115 | # qmk_firmware/keyboards |
| 115 | keyboards_dir = os.path.join(os.getcwd(), "keyboards") | 116 | keyboards_dir = Path.cwd() / "keyboards" |
| 116 | # path to the keyboard's directory | 117 | # path to the keyboard's directory |
| 117 | kb_path = os.path.join(keyboards_dir, keyboard_name) | 118 | kb_path = keyboards_dir / keyboard_name |
| 118 | # walk up the directory tree until keyboards_dir | 119 | # walk up the directory tree until keyboards_dir |
| 119 | # and collect all directories' name with keymap.c file in it | 120 | # and collect all directories' name with keymap.c file in it |
| 120 | while kb_path != keyboards_dir: | 121 | while kb_path != keyboards_dir: |
| 121 | keymaps_dir = os.path.join(kb_path, "keymaps") | 122 | keymaps_dir = kb_path / "keymaps" |
| 122 | if os.path.exists(keymaps_dir): | 123 | if keymaps_dir.exists(): |
| 123 | names = names.union([keymap for keymap in os.listdir(keymaps_dir) if os.path.isfile(os.path.join(keymaps_dir, keymap, "keymap.c"))]) | 124 | names = names.union([keymap for keymap in os.listdir(keymaps_dir) if (keymaps_dir / keymap / "keymap.c").is_file()]) |
| 124 | kb_path = os.path.dirname(kb_path) | 125 | kb_path = kb_path.parent |
| 125 | 126 | ||
| 126 | # if community layouts are supported, get them | 127 | # if community layouts are supported, get them |
| 127 | if "LAYOUTS" in rules_mk: | 128 | if "LAYOUTS" in rules_mk: |
| 128 | for layout in rules_mk["LAYOUTS"].split(): | 129 | for layout in rules_mk["LAYOUTS"].split(): |
| 129 | cl_path = os.path.join(os.getcwd(), "layouts", "community", layout) | 130 | cl_path = Path.cwd() / "layouts" / "community" / layout |
| 130 | if os.path.exists(cl_path): | 131 | if cl_path.exists(): |
| 131 | names = names.union([keymap for keymap in os.listdir(cl_path) if os.path.isfile(os.path.join(cl_path, keymap, "keymap.c"))]) | 132 | names = names.union([keymap for keymap in os.listdir(cl_path) if (cl_path / keymap / "keymap.c").is_file()]) |
| 132 | 133 | ||
| 133 | return sorted(names) | 134 | return sorted(names) |
