diff options
| author | Barry Warsaw | 2007-12-29 01:13:38 -0500 |
|---|---|---|
| committer | Barry Warsaw | 2007-12-29 01:13:38 -0500 |
| commit | b7fc1a2cd9cc63f9bfafb6d3e7a28f3b64f3ed97 (patch) | |
| tree | e33933b88fc4fd7e108c174da6292946bd9128e7 /Mailman/app/rules.py | |
| parent | 306a1ceee0aad4c623f029d8809b40f7f55b9a6f (diff) | |
| download | mailman-b7fc1a2cd9cc63f9bfafb6d3e7a28f3b64f3ed97.tar.gz mailman-b7fc1a2cd9cc63f9bfafb6d3e7a28f3b64f3ed97.tar.zst mailman-b7fc1a2cd9cc63f9bfafb6d3e7a28f3b64f3ed97.zip | |
Diffstat (limited to 'Mailman/app/rules.py')
| -rw-r--r-- | Mailman/app/rules.py | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Mailman/app/rules.py b/Mailman/app/rules.py index 152694177..37f5d9af4 100644 --- a/Mailman/app/rules.py +++ b/Mailman/app/rules.py @@ -17,6 +17,11 @@ """Process all rules defined by entry points.""" +__all__ = [ + 'find_rule', + 'process', + ] + from Mailman.app.plugins import get_plugins @@ -24,8 +29,7 @@ from Mailman.app.plugins import get_plugins def process(mlist, msg, msgdata, rule_set=None): """Default rule processing plugin. - Rules are processed in random order so a rule should not permanently alter - a message or the message metadata. + Rules are processed in random order. :param msg: The message object. :param msgdata: The message metadata. @@ -44,3 +48,17 @@ def process(mlist, msg, msgdata, rule_set=None): if rule.check(mlist, msg, msgdata): rule_matches.add(rule.name) return rule_matches + + + +def find_rule(rule_name): + """Find the named rule. + + :param rule_name: The name of the rule to find. + :return: The named rule, or None if no such rule exists. + """ + for rule_set_class in get_plugins('mailman.rules'): + rule = rule_set_class().get(rule_name) + if rule is not None: + return rule + return None |
