diff options
Diffstat (limited to 'modules/mm_utils.py')
| -rw-r--r-- | modules/mm_utils.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/modules/mm_utils.py b/modules/mm_utils.py index ca6c6f429..b29a9f8bf 100644 --- a/modules/mm_utils.py +++ b/modules/mm_utils.py @@ -188,3 +188,29 @@ def UnobscureEmail(addr): # Contrived to act as an identity operation on already-unobscured # emails, so routines expecting obscured ones will accept both. return re.sub("__at__", "@", addr) + +def map_maillists(func, names=None, unlock=None, verbose=0): + """Apply function (of one argument) to all list objs in turn. + + Returns a list of the results. + + Optional arg 'names' specifies which lists, default all. + Optional arg unlock says to unlock immediately after instantiation. + Optional arg verbose says to print list name as it's about to be + instantiated, CR when instantiation is complete, and result of + application as it shows.""" + from maillist import MailList + if names == None: names = list_names() + got = [] + for i in names: + if verbose: print i, + l = MailList(i) + if verbose: print + if unlock: + l.Unlock() + got.append(apply(func, (l,))) + if verbose: print got[-1] + if not unlock: + l.Unlock() + del l + return got |
