This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new f9ef562  These are constants
f9ef562 is described below

commit f9ef562fd74e9a66a986556b16908ea2ff0c0b4d
Author: Sebb <[email protected]>
AuthorDate: Fri Nov 26 23:33:11 2021 +0000

    These are constants
---
 tools/archiver.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/archiver.py b/tools/archiver.py
index b3859ea..c301253 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -340,7 +340,7 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
         name = "foal"
 
     # This is a list of headers which are stored in msg_metadata
-    keys = [
+    HDR_KEYS = [
         "archived-at",
         "delivered-to",
         "from",
@@ -357,6 +357,8 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
         "x-mailman-rule-hits",
         "x-mailman-rule-misses",
     ]
+    # keys that need to be decoded
+    HDR_KEYS_DECODE = ["to", "from", "subject", "message-id"]
 
     def __init__(
         self, generator=None, parse_html=False, ignore_body=None, verbose=False
@@ -456,7 +458,7 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
 
         def default_empty_string(value):
             return str(value) if value else ""
-        msg_metadata = dict([(k, default_empty_string(msg.get(k))) for k in 
self.keys])
+        msg_metadata = dict([(k, default_empty_string(msg.get(k))) for k in 
self.HDR_KEYS])
         mid = (
             hashlib.sha224(
                 str("%s-%s" % (lid, 
msg_metadata["archived-at"])).encode("utf-8")
@@ -464,7 +466,7 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
             + "@"
             + (lid if lid else "none")
         )
-        for key in ["to", "from", "subject", "message-id"]:
+        for key in self.HDR_KEYS_DECODE:
             try:
                 hval = ""
                 if msg_metadata.get(key):

Reply via email to