Skip to content

Commit

Permalink
Merge pull request #286 from dajt1725/config-parameter-list
Browse files Browse the repository at this point in the history
In the config file, accept lists of possible values, and the rule matches if the attribute is any of the specified values.
  • Loading branch information
coldfix authored Apr 21, 2024
2 parents 372a34e + 37b65b9 commit 8a4f461
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion doc/udiskie.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,14 @@ device_config:
# The rules defined here are simply prepended to the builtin device rules,
# so that it is possible to completely overwrite the defaults by specifying
# a catch-all rule (i.e. a rule without device attributes).
# Filter rules can be passed a list of values, in which case the rule is matched
# if the attribute matches any of the values in the list.

- device_file: /dev/dm-5 # [filter]
ignore: false # [action] never ignore this device
- id_uuid: 9d53-13ba # [filter] match by device UUID
- id_uuid: # [filter] match by device UUID
- 9d53-13ba # This rule matches on either of these uids
- 8675-309a
options: [noexec, nodev] # [action] mount options can be given as list
ignore: false # [action] never ignore this device (even if fs=FAT)
automount: false # [action] do not automount this device
Expand Down
1 change: 1 addition & 0 deletions udiskie/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# the two identically named python packages (=keyring).
from keyutils import KEY_SPEC_PROCESS_KEYRING


class PasswordCache:

def __init__(self, timeout):
Expand Down
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 8a4f461

Please sign in to comment.