diff options
author | Erovia <erovia@users.noreply.github.com> | 2019-10-24 22:22:44 +0200 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2020-02-15 15:19:03 -0800 |
commit | 4445e0a459ce891d6e51a252030f665fea355b41 (patch) | |
tree | 9b9a197ed72555e571434987f9eea0ad373a5735 /lib/python | |
parent | 3ed1223678d3ec40f4cceecd320dd1112cdfb157 (diff) |
Return only the unique keymaps
Diffstat (limited to 'lib/python')
-rw-r--r-- | lib/python/qmk/keymap.py | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index 3927f791a6..6ee60b8be1 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): community: Set to True for the layouts under layouts/community. Returns: - a list with whe keymaps's names + a set with the keymaps's names """ path_wildcard = os.path.join(base_path, "**", "keymap.c") if community: @@ -119,7 +119,7 @@ def find_keymaps(base_path, revision = "", community = False): else: 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") names = [path_regex.sub(lambda name: name.group(1), path) for path in glob.iglob(path_wildcard, recursive = True) if path_regex.search(path)] - return names + return set(names) def list_keymaps(keyboard_name): """ List the available keymaps for a keyboard. @@ -128,7 +128,7 @@ def list_keymaps(keyboard_name): keyboard_name: the keyboards full name with vendor and revision if necessary, example: clueboard/66/rev3 Returns: - a list with the names of the available keymaps + a set with the names of the available keymaps """ if os.path.sep in keyboard_name: keyboard, revision = os.path.split(os.path.normpath(keyboard_name)) @@ -138,7 +138,7 @@ def list_keymaps(keyboard_name): # parse all the rules.mk files for the keyboard rules_mk = qmk.makefile.get_rules_mk(keyboard, revision) - names = list() + names = set() if rules_mk: # get the keymaps from the keyboard's directory @@ -151,5 +151,4 @@ def list_keymaps(keyboard_name): cl_base_path = os.path.join(os.getcwd(), "layouts", "community", layout) + os.path.sep names = names + find_keymaps(cl_base_path, revision, community = True) - names.sort() - return names + return sorted(names) |