diff options
| author | Mark Sapiro | 2017-07-26 08:11:33 -0700 |
|---|---|---|
| committer | Mark Sapiro | 2017-07-26 08:11:33 -0700 |
| commit | bea94cb9538a55b1376afd42c2ce751efce62cfe (patch) | |
| tree | 5fba570b0c6f4c0919009cb6f455c18bc732192a /src/mailman/chains/base.py | |
| parent | 02826321d0430d7ffc1f674eeff4221941689ef7 (diff) | |
| download | mailman-bea94cb9538a55b1376afd42c2ce751efce62cfe.tar.gz mailman-bea94cb9538a55b1376afd42c2ce751efce62cfe.tar.zst mailman-bea94cb9538a55b1376afd42c2ce751efce62cfe.zip | |
Diffstat (limited to 'src/mailman/chains/base.py')
| -rw-r--r-- | src/mailman/chains/base.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mailman/chains/base.py b/src/mailman/chains/base.py index 59125ba69..9507d8fbc 100644 --- a/src/mailman/chains/base.py +++ b/src/mailman/chains/base.py @@ -18,6 +18,7 @@ """Base class for terminal chains.""" from mailman.config import config +from mailman.core.i18n import _ from mailman.interfaces.chain import ( IChain, IChainIterator, IChainLink, IMutableChain, LinkAction) from mailman.interfaces.rules import IRule @@ -27,6 +28,24 @@ from zope.interface import implementer @public +def format_reasons(reasons): + """Translate and format hold and rejection reasons. + + :param reasons: A list of reasons from the rules that hit. Each reason is + a string to be translated or a tuple consisting of a string with {} + replacements and one or more replacement values. + :returns: A list of the translated and formatted strings. + """ + new_reasons = [] + for reason in reasons: + if isinstance(reason, tuple): + new_reasons.append(_(reason[0]).format(*reason[1:])) + else: + new_reasons.append(_(reason)) + return new_reasons + + +@public @implementer(IChainLink) class Link: """A chain link.""" |
