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.git
The following commit(s) were added to refs/heads/master by this push:
new d7a9606 Does not need to be class method
d7a9606 is described below
commit d7a96069b3d6e30517e54b25a31e44408f196ded
Author: Sebb <[email protected]>
AuthorDate: Sat Aug 22 21:55:11 2020 +0100
Does not need to be class method
---
tools/archiver.py | 22 +++++++++++-----------
tools/import-mbox.py | 2 +-
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/tools/archiver.py b/tools/archiver.py
index f3410ce..64f7844 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -90,6 +90,15 @@ def encode_base64(buff):
""" Convert bytes to base64 as text string (no newlines) """
return base64.standard_b64encode(buff).decode('ascii', 'ignore')
+def mbox_source(b):
+ # Common method shared with import-mbox
+ try:
+ # Can we store as ASCII?
+ return b.decode('ascii', errors='strict')
+ except UnicodeError:
+ # No, so must use base64 to avoid corruption on re-encoding
+ return encode_base64(b)
+
def parse_attachment(part):
cd = part.get("Content-Disposition", None)
if cd:
@@ -451,7 +460,7 @@ class Archiver(object): # N.B. Also used by import-mbox.py
consistency = self.consistency,
body = {
"message-id": msg_metadata['message-id'],
- "source": self.mbox_source(raw_message)
+ "source": mbox_source(raw_message)
}
)
# If we have a dump dir and ES failed, push to dump dir instead as a
JSON object
@@ -467,7 +476,7 @@ class Archiver(object): # N.B. Also used by import-mbox.py
'mbox': ojson,
'mbox_source': {
"message-id": msg_metadata['message-id'],
- "source": self.mbox_source(raw_message)
+ "source": mbox_source(raw_message)
},
'attachments': contents
},f , indent = 2)
@@ -565,15 +574,6 @@ class Archiver(object): # N.B. Also used by import-mbox.py
logger.info("Notification sent to %s for %s", cid,
mid)
return lid, ojson['mid']
- def mbox_source(self, b):
- # Common method shared with import-mbox
- try:
- # Can we store as ASCII?
- return b.decode('ascii', errors='strict')
- except UnicodeError:
- # No, so must use base64 to avoid corruption on re-encoding
- return encode_base64(b)
-
def list_url(self, _mlist):
""" Required by MM3 plugin API
"""
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index 8e10b39..007257f 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -281,7 +281,7 @@ class SlurpThread(Thread):
json_source = {
'mid': json['mid'], # needed for bulk-insert only,
not needed in database
'message-id': json['message-id'],
- 'source': archie.mbox_source(raw_msg)
+ 'source': archiver.mbox_source(raw_msg)
}
except Exception as e:
self.printid("Error '%s' processing id %s msg %s " %
(e, json['mid'], json['message-id']))