diff options
| author | bwarsaw | 2001-10-15 21:40:56 +0000 |
|---|---|---|
| committer | bwarsaw | 2001-10-15 21:40:56 +0000 |
| commit | f11cf4d491cdf0364902d995988e6c514bf87732 (patch) | |
| tree | 51420ad0969126eae78caadd3c7baa8f10736c75 | |
| parent | df280ac14b9ca4c84524e992889c4ad4472b5a26 (diff) | |
| download | mailman-f11cf4d491cdf0364902d995988e6c514bf87732.tar.gz mailman-f11cf4d491cdf0364902d995988e6c514bf87732.tar.zst mailman-f11cf4d491cdf0364902d995988e6c514bf87732.zip | |
List2Dict(): Add `foldcase' argument. When true, coerce all elements
in the dict to lowercase (yes they must be strings).
| -rw-r--r-- | Mailman/Utils.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/Mailman/Utils.py b/Mailman/Utils.py index 2a2bfc41e..5ffdb99c7 100644 --- a/Mailman/Utils.py +++ b/Mailman/Utils.py @@ -275,13 +275,16 @@ def GetPossibleMatchingAddrs(name): -def List2Dict(list): - """List2Dict returns a dict keyed by the entries in the list - passed to it.""" - res = {} - for item in list: - res[item] = 1 - return res +def List2Dict(list, foldcase=0): + """Return a dict keyed by the entries in the list passed to it.""" + d = {} + if foldcase: + for i in list: + d[i.lower()] = 1 + else: + for i in list: + d[i] = 1 + return d def FindMatchingAddresses(name, dict, *dicts): |
