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 d4e3c57  Make output quieter
d4e3c57 is described below

commit d4e3c570b64960e8550ac0618ea488698e5e6c4a
Author: Sebb <[email protected]>
AuthorDate: Sun Aug 23 15:09:46 2020 +0100

    Make output quieter
---
 tools/archiver.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/archiver.py b/tools/archiver.py
index 8cc2243..5c9b41b 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -97,7 +97,7 @@ def mbox_source(b):
         # No, so must use base64 to avoid corruption on re-encoding
         return encode_base64(b)
 
-def parse_attachment(part):
+def parse_attachment(part, verbose=False):
     cd = part.get("Content-Disposition", None)
     if cd:
         # Use str() in case the name is not in ASCII.
@@ -110,7 +110,8 @@ def parse_attachment(part):
             if fd is None: return None, None
             filename = part.get_filename()
             if filename:
-                print("Found attachment: %s" % filename)
+                if verbose:
+                    print("Found attachment: %s" % filename)
                 attachment = {'content_type': part.get_content_type(), 'size': 
len(fd), 'filename': filename}
                 h = hashlib.sha256(fd).hexdigest()
                 b64 = encode_base64(fd)
@@ -243,7 +244,7 @@ class Archiver(object): # N.B. Also used by import-mbox.py
         attachments = []
         contents = {}
         for part in msg.walk():
-            part_meta, part_file = parse_attachment(part)
+            part_meta, part_file = parse_attachment(part, self.verbose)
             if part_meta:
                 attachments.append(part_meta)
                 contents[part_meta['hash']] = part_file

Reply via email to