Skip to content

Commit

Permalink
accept a list of possible values for in match_value()
Browse files Browse the repository at this point in the history
This means instead of having ten rules, each of which matches a single uuid, you can provide a list of uuids to a single rule.
  • Loading branch information
dajt1725 authored Apr 21, 2024
1 parent 372a34e commit 6ca5802
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions udiskie/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def _format_item(k, v):
def match_value(value, pattern):
if isinstance(value, (list, tuple)):
return any(match_value(v, pattern) for v in value)
if isinstance(pattern, (list, tuple)):
return any(match_value(value, p) for p in pattern)
if isinstance(value, str) and isinstance(pattern, str):
return fnmatch.fnmatch(value.lower(), pattern.lower())
return lower(value) == lower(pattern)
Expand Down

0 comments on commit 6ca5802

Please sign in to comment.