aboutsummaryrefslogtreecommitdiff
path: root/lib/python/qmk
diff options
context:
space:
mode:
authorErovia <erovia@users.noreply.github.com>2019-10-24 22:22:44 +0200
committerskullydazed <skullydazed@users.noreply.github.com>2020-02-15 15:19:03 -0800
commit4445e0a459ce891d6e51a252030f665fea355b41 (patch)
tree9b9a197ed72555e571434987f9eea0ad373a5735 /lib/python/qmk
parent3ed1223678d3ec40f4cceecd320dd1112cdfb157 (diff)
downloadqmk_firmware-4445e0a459ce891d6e51a252030f665fea355b41.tar.gz
qmk_firmware-4445e0a459ce891d6e51a252030f665fea355b41.zip
Return only the unique keymaps
Diffstat (limited to 'lib/python/qmk')
-rw-r--r--lib/python/qmk/keymap.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py
index 3927f791a..6ee60b8be 100644
--- a/lib/python/qmk/keymap.py
+++ b/lib/python/qmk/keymap.py
@@ -111,7 +111,7 @@ def find_keymaps(base_path, revision = "", community = False):
111 community: Set to True for the layouts under layouts/community. 111 community: Set to True for the layouts under layouts/community.
112 112
113 Returns: 113 Returns:
114 a list with whe keymaps's names 114 a set with the keymaps's names
115 """ 115 """
116 path_wildcard = os.path.join(base_path, "**", "keymap.c") 116 path_wildcard = os.path.join(base_path, "**", "keymap.c")
117 if community: 117 if community:
@@ -119,7 +119,7 @@ def find_keymaps(base_path, revision = "", community = False):
119 else: 119 else:
120 path_regex = re.compile(r"^" + re.escape(base_path) + "(?:" + re.escape(revision) + os.path.sep + ")?keymaps" + os.path.sep + "(\S+)" + os.path.sep + "keymap\.c") 120 path_regex = re.compile(r"^" + re.escape(base_path) + "(?:" + re.escape(revision) + os.path.sep + ")?keymaps" + os.path.sep + "(\S+)" + os.path.sep + "keymap\.c")
121 names = [path_regex.sub(lambda name: name.group(1), path) for path in glob.iglob(path_wildcard, recursive = True) if path_regex.search(path)] 121 names = [path_regex.sub(lambda name: name.group(1), path) for path in glob.iglob(path_wildcard, recursive = True) if path_regex.search(path)]
122 return names 122 return set(names)
123 123
124def list_keymaps(keyboard_name): 124def list_keymaps(keyboard_name):
125 """ List the available keymaps for a keyboard. 125 """ List the available keymaps for a keyboard.
@@ -128,7 +128,7 @@ def list_keymaps(keyboard_name):
128 keyboard_name: the keyboards full name with vendor and revision if necessary, example: clueboard/66/rev3 128 keyboard_name: the keyboards full name with vendor and revision if necessary, example: clueboard/66/rev3
129 129
130 Returns: 130 Returns:
131 a list with the names of the available keymaps 131 a set with the names of the available keymaps
132 """ 132 """
133 if os.path.sep in keyboard_name: 133 if os.path.sep in keyboard_name:
134 keyboard, revision = os.path.split(os.path.normpath(keyboard_name)) 134 keyboard, revision = os.path.split(os.path.normpath(keyboard_name))
@@ -138,7 +138,7 @@ def list_keymaps(keyboard_name):
138 138
139 # parse all the rules.mk files for the keyboard 139 # parse all the rules.mk files for the keyboard
140 rules_mk = qmk.makefile.get_rules_mk(keyboard, revision) 140 rules_mk = qmk.makefile.get_rules_mk(keyboard, revision)
141 names = list() 141 names = set()
142 142
143 if rules_mk: 143 if rules_mk:
144 # get the keymaps from the keyboard's directory 144 # get the keymaps from the keyboard's directory
@@ -151,5 +151,4 @@ def list_keymaps(keyboard_name):
151 cl_base_path = os.path.join(os.getcwd(), "layouts", "community", layout) + os.path.sep 151 cl_base_path = os.path.join(os.getcwd(), "layouts", "community", layout) + os.path.sep
152 names = names + find_keymaps(cl_base_path, revision, community = True) 152 names = names + find_keymaps(cl_base_path, revision, community = True)
153 153
154 names.sort() 154 return sorted(names)
155 return names