You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2016/10/29 22:38:44 UTC

incubator-ponymail git commit: import-mbox.py does not handle protocol choice well

Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 6a8e2ce83 -> a4ce196e1


import-mbox.py does not handle protocol choice well

This fixes #135

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/a4ce196e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/a4ce196e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/a4ce196e

Branch: refs/heads/master
Commit: a4ce196e14b498d3b3a86da736d10d1b7403a71a
Parents: 6a8e2ce
Author: Sebb <se...@apache.org>
Authored: Sat Oct 29 23:38:26 2016 +0100
Committer: Sebb <se...@apache.org>
Committed: Sat Oct 29 23:38:26 2016 +0100

----------------------------------------------------------------------
 tools/import-mbox.py | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/a4ce196e/tools/import-mbox.py
----------------------------------------------------------------------
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index ae505bf..7bd2c7f 100644
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -356,7 +356,7 @@ tlpname = "foo"
 
 parser = argparse.ArgumentParser(description='Command line options.')
 parser.add_argument('--source', dest='source', type=str, nargs=1,
-                   help='Source to scan (either http(s):// or file path)')
+                   help='Source to scan (http(s)://, imap(s):// or file path)')
 parser.add_argument('--dir', dest='dir', action='store_true',
                    help='Input is in Maildir format')
 parser.add_argument('--interactive', dest='interactive', action='store_true',
@@ -456,18 +456,8 @@ def globDir(d):
         globDir(join(d,nd))
  
 
-# File based import??
-if source[0] == "/" or source[0] == ".":
-    print("Doing file based import")
-    filebased = True
-    if maildir:
-        lists.append([source, fileToLID.get(source) if fileToLID.get(source) else list_override])
-    else:
-        globDir(source)
-    
-
 # HTTP(S) based import?
-elif source[0] == "h":
+if re.match(r"https?://", source):
     data = urlopen(source).read().decode('utf-8')
     print("Fetched %u bytes of main data, parsing month lists" % len(data))
     
@@ -518,7 +508,7 @@ elif source[0] == "h":
                 break
                     
 # IMAP(S) based import?
-elif source[0] == "i":
+elif re.match(r"imaps?://", source):
     imap = True
     import urllib, getpass, imaplib
     url = urllib.parse.urlparse(source)
@@ -612,6 +602,15 @@ elif source[0] == "i":
         if not mid in db:
             uids.append(uid)
     lists.append([uids, listname, imap4])
+else:
+    # File based import??
+    print("Doing file based import")
+    filebased = True
+    if maildir:
+        lists.append([source, fileToLID.get(source) if fileToLID.get(source) else list_override])
+    else:
+        globDir(source)
+
 
 threads = []
 # Don't start more threads than there are lists