ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [incubator-ponymail] branch master updated: Enh: make MboxoFactory optional
Date Wed, 07 Mar 2018 18:22:51 GMT
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 4faa89f  Enh: make MboxoFactory optional
4faa89f is described below

commit 4faa89fb0aed54d5e03bd6fc280280e372d0a4ac
Author: Sebb <sebb@apache.org>
AuthorDate: Wed Mar 7 18:22:49 2018 +0000

    Enh: make MboxoFactory optional
    
    This fixes #442
---
 CHANGELOG.md         |  1 +
 tools/import-mbox.py | 18 ++++++++++++------
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index d5dac29..62f5479 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
 ## Changes in 0.11-SNAPSHOT
+- Enh: make MboxoFactory optional (#442)
 - Bug: duplication of data in response from thread.lua (#440)
 - Bug: Indentation in mail content (leading white-space) not shown (#432)
 - Bug: does not make sense to allow empty domain name in LID (#434)
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index 8154296..efbcc84 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -35,10 +35,6 @@ import multiprocessing
 import tempfile
 import gzip
 
-# Temporary patch to fix Python email package limitation
-# It must be removed when the Python package is fixed
-from mboxo_patch import MboxoFactory, MboxoReader
-
 try:
     from elasticsearch import Elasticsearch, helpers
     from formatflowed import convertToWrapped # only needed by archiver
@@ -81,6 +77,7 @@ timeout = 600
 fromFilter = None
 dedup = False
 dedupped = 0
+noMboxo = False # Don't skip MBoxo patch
 
 # Fetch config
 path = os.path.dirname(os.path.realpath(__file__))
@@ -213,7 +210,7 @@ class SlurpThread(Thread):
                     except Exception as err:
                         self.printid("This wasn't a gzip file: %s" % err )
                 self.printid("Slurping %s" % filename)
-                messages = mailbox.mbox(tmpname, MboxoFactory, create=False)
+                messages = mailbox.mbox(tmpname, None if noMboxo else MboxoFactory, create=False)
 
             else:
                 ml = mla[0]
@@ -231,7 +228,7 @@ class SlurpThread(Thread):
                 tmpname = hashlib.sha224(("%f-%f-%s-%s.mbox" % (random.random(), time.time(),
ml, mboxfile)).encode('utf-8') ).hexdigest()
                 with open(tmpname, "w") as f:
                     f.write(inp)
-                messages = mailbox.mbox(tmpname, MboxoFactory, create=False)
+                messages = mailbox.mbox(tmpname, None if noMboxo else MboxoFactory, create=False)
 
             count = 0
             bad = 0
@@ -425,6 +422,8 @@ parser.add_argument('--timeout', dest='timeout', type=int, nargs=1,
                    help='Optional timeout in secs for importing an mbox/maildir file (default
is 600 seconds)')
 parser.add_argument('--filter', dest = 'fromfilter', type=str, nargs=1,
                     help = 'Optional sender filter: Only import emails from this address')
+parser.add_argument('--nomboxo', dest = 'nomboxo', action='store_true',
+                    help = 'Skip Mboxo processing')
 
 args = parser.parse_args()
 
@@ -461,6 +460,13 @@ if args.ibody:
     archiver.iBody = args.ibody[0]
 if args.fromfilter:
     fromFilter = args.fromfilter[0]
+if args.nomboxo:
+    noMboxo = args.nomboxo
+else:
+    # Temporary patch to fix Python email package limitation
+    # It must be removed when the Python package is fixed
+    from mboxo_patch import MboxoFactory, MboxoReader
+
 if args.resend:
     resendTo = args.resend[0]
     from smtplib import SMTP

-- 
To stop receiving notification emails like this one, please contact
sebb@apache.org.

Mime
View raw message