summaryrefslogtreecommitdiff
path: root/src/mailman/utilities
diff options
context:
space:
mode:
authorAurélien Bompard2016-02-02 18:10:18 +0100
committerBarry Warsaw2016-02-29 21:52:13 -0500
commit994660913bbd7dc08b8cef909b6715f43d37f0d5 (patch)
treed17930b6d325f2d785883dc17ea71cf6eaef848f /src/mailman/utilities
parent9bf90986117e39450ec5bf1f86d29e5ed91f480d (diff)
downloadmailman-994660913bbd7dc08b8cef909b6715f43d37f0d5.tar.gz
mailman-994660913bbd7dc08b8cef909b6715f43d37f0d5.tar.zst
mailman-994660913bbd7dc08b8cef909b6715f43d37f0d5.zip
Diffstat (limited to 'src/mailman/utilities')
-rw-r--r--src/mailman/utilities/importer.py14
-rw-r--r--src/mailman/utilities/tests/test_import.py6
2 files changed, 10 insertions, 10 deletions
diff --git a/src/mailman/utilities/importer.py b/src/mailman/utilities/importer.py
index 52de967cf..8a37d909e 100644
--- a/src/mailman/utilities/importer.py
+++ b/src/mailman/utilities/importer.py
@@ -129,7 +129,7 @@ def nonmember_action_mapping(value):
}[value]
-def action_to_chain(value):
+def action_to_enum(value):
# Converts an action number in Mailman 2.1 to the name of the corresponding
# chain in 3.x. The actions 'approve', 'subscribe' and 'unsubscribe' are
# ignored. The defer action is converted to None, because it is not
@@ -137,12 +137,12 @@ def action_to_chain(value):
return {
0: None,
#1: 'approve',
- 2: 'reject',
- 3: 'discard',
+ 2: Action.reject,
+ 3: Action.discard,
#4: 'subscribe',
#5: 'unsubscribe',
- 6: 'accept',
- 7: 'hold',
+ 6: Action.accept,
+ 7: Action.hold,
}[value]
@@ -337,7 +337,7 @@ def import_config_pck(mlist, config_dict):
header_filter_rules = config_dict.get('header_filter_rules', [])
for line_patterns, action, _unused in header_filter_rules:
try:
- chain = action_to_chain(action)
+ action = action_to_enum(action)
except KeyError:
log.warning('Unsupported header_filter_rules action: %r',
action)
@@ -374,7 +374,7 @@ def import_config_pck(mlist, config_dict):
'invalid regular expression: %r', line_pattern)
continue
try:
- header_matches.append(header, pattern, chain)
+ header_matches.append(header, pattern, action)
except ValueError:
log.warning('Skipping duplicate header_filter rule: %r',
line_pattern)
diff --git a/src/mailman/utilities/tests/test_import.py b/src/mailman/utilities/tests/test_import.py
index 68a005760..1b7c1d60e 100644
--- a/src/mailman/utilities/tests/test_import.py
+++ b/src/mailman/utilities/tests/test_import.py
@@ -367,7 +367,7 @@ class TestBasicImport(unittest.TestCase):
error_log = LogFileMark('mailman.error')
self._import()
self.assertListEqual(
- [(hm.header, hm.pattern, hm.chain)
+ [(hm.header, hm.pattern, hm.action.name)
for hm in self._mlist.header_matches ], [
('x-spam-status', 'Yes.*', 'discard'),
('x-spam-status', 'Yes', 'reject'),
@@ -445,7 +445,7 @@ class TestBasicImport(unittest.TestCase):
]
self._import()
self.assertListEqual(
- [(hm.header, hm.pattern, hm.chain)
+ [(hm.header, hm.pattern, hm.action)
for hm in self._mlist.header_matches],
[('x-spam-status', 'Yes', None)]
)
@@ -476,7 +476,7 @@ class TestBasicImport(unittest.TestCase):
error_log = LogFileMark('mailman.error')
self._import()
self.assertListEqual(
- [(hm.header, hm.pattern, hm.chain)
+ [(hm.header, hm.pattern, hm.action.name)
for hm in self._mlist.header_matches],
[('someheadername', 'test-pattern', 'discard')]
)