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: allow generator to be overridden for testing
Date Tue, 13 Aug 2019 22:30:23 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 0acfd04  Enh: allow generator to be overridden for testing
0acfd04 is described below

commit 0acfd049357b144af8abc2672704e7a93cf6af3c
Author: Sebb <sebb@apache.org>
AuthorDate: Tue Aug 13 23:30:09 2019 +0100

    Enh: allow generator to be overridden for testing
    
    This fixes #506
---
 CHANGELOG.md         | 1 +
 tools/archiver.py    | 4 ++++
 tools/import-mbox.py | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index f75216a..28be888 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,5 @@
 ## Changes in 0.12:
+- Enh: allow generator to be overridden for testing (#506)
 - Bug: generator.py does not include original medium generator (#505)
 - Enh: move generator selection to generator.py (#504)
 - Bug: Bug: parser fails to extract inline attachments (#501)
diff --git a/tools/archiver.py b/tools/archiver.py
index d965b71..4fd7f52 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -590,6 +590,8 @@ if __name__ == '__main__':
                        help='Do not save emails to elasticsearch, only test parsing')
     parser.add_argument('--dumponfail', dest='dump',
                        help='If pushing to ElasticSearch fails, dump documents in JSON format
to this directory and fail silently.')
+    parser.add_argument('--generator', dest='generator',
+                       help='Override the generator.')
     args = parser.parse_args()
 
     if args.html2text:
@@ -603,6 +605,8 @@ if __name__ == '__main__':
         # Also eliminates: 'Undecodable raw error response from server:' warning message
         logging.getLogger("elasticsearch").setLevel(logging.ERROR)
 
+    if args.generator:
+        archiver_generator = args.generator
 
     archie = Archiver(parseHTML = parseHTML)
     # use binary input so parser can use appropriate charset
diff --git a/tools/import-mbox.py b/tools/import-mbox.py
index e2a6a2d..ea490ea 100755
--- a/tools/import-mbox.py
+++ b/tools/import-mbox.py
@@ -371,6 +371,8 @@ 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')
+parser.add_argument('--generator', dest='generator',
+                   help='Override the generator.')
 
 args = parser.parse_args()
 
@@ -440,6 +442,8 @@ else:
         print("Error: unable to check if the index %s exists!: %s" % (dbname, err))
         sys.exit(1)
 
+if args.generator:
+    archiver.archiver_generator = args.generator
 
 def globDir(d):
     dirs = [ f for f in listdir(d) if isdir(join(d,f)) ]


Mime
View raw message