summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Brassel <nick@tzarc.org>2023-01-19 09:36:32 +1100
committerGitHub <noreply@github.com>2023-01-18 22:36:32 +0000
commit17c9388af5432f8e6d97828f6772eaf8031a786b (patch)
tree085beef7a618cd06e66189ed03347489b8f1facb
parentd73ad5204049648a912fe3b384b36d211570b544 (diff)
Allow for wildcard filtering in `qmk mass-compile` (#19625)
-rwxr-xr-xlib/python/qmk/cli/mass_compile.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/python/qmk/cli/mass_compile.py b/lib/python/qmk/cli/mass_compile.py
index b5f12c5026..a98f7ad482 100755
--- a/lib/python/qmk/cli/mass_compile.py
+++ b/lib/python/qmk/cli/mass_compile.py
@@ -2,6 +2,7 @@
This will compile everything in parallel, for testing purposes.
"""
+import fnmatch
import logging
import multiprocessing
import os
@@ -58,7 +59,8 @@ def _load_keymap_info(keyboard, keymap):
arg_only=True,
action='append',
default=[],
- help="Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the format 'features.rgblight=true'. May be passed multiple times, all filters need to match."
+ help= # noqa: `format-python` and `pytest` don't agree here.
+ "Filter the list of keyboards based on the supplied value in rules.mk. Matches info.json structure, and accepts the format 'features.rgblight=true'. May be passed multiple times, all filters need to match. Value may include wildcards such as '*' and '?'." # noqa: `format-python` and `pytest` don't agree here.
)
@cli.argument('-km', '--keymap', type=str, default='default', help="The keymap name to build. Default is 'default'.")
@cli.argument('-e', '--env', arg_only=True, action='append', default=[], help="Set a variable to be passed to make. May be passed multiple times.")
@@ -102,11 +104,13 @@ def mass_compile(cli):
cli.log.info(f'Filtering on condition ("{key}" == "{value}")...')
def _make_filter(k, v):
+ expr = fnmatch.translate(v)
+ rule = re.compile(expr, re.IGNORECASE)
+
def f(e):
lhs = e[2].get(k)
- lhs = str(False if lhs is None else lhs).lower()
- rhs = str(v).lower()
- return lhs == rhs
+ lhs = str(False if lhs is None else lhs)
+ return rule.search(lhs) is not None
return f