This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git


The following commit(s) were added to refs/heads/master by this push:
     new c878d4b  Add a --digest option for just printing the generated 
document ID, nothing else.
c878d4b is described below

commit c878d4b79288cfcdbe59e7a560c7a9da3ba87a03
Author: Daniel Gruno <[email protected]>
AuthorDate: Wed Jan 12 20:07:06 2022 +0100

    Add a --digest option for just printing the generated document ID, nothing 
else.
---
 tools/archiver.py | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/tools/archiver.py b/tools/archiver.py
index 986dadb..f012ea3 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -636,7 +636,7 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
 
         return output_json, contents, msg_metadata, irt, False
 
-    def archive_message(self, mlist, msg, raw_message=None, dry=False, 
dump=None, defaultepoch=None):
+    def archive_message(self, mlist, msg, raw_message=None, dry=False, 
dump=None, defaultepoch=None, digest=False):
         """Send the message to the archiver.
 
         :param mlist: The IMailingList object.
@@ -674,6 +674,8 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
         if skipit:
             print("Skipping archiving of email due to invalid date and default 
date set to skip")
             return lid, "(skipped)"
+        if digest:
+            return lid, ojson["mid"]
         if dry:
             print("**** Dry run, not saving message to database *****")
             return lid, ojson["mid"]
@@ -873,6 +875,12 @@ def main():
         "--lid", dest="lid", type=str, nargs=1, help="Alternate specific list 
ID"
     )
     parser.add_argument(
+        "--digest",
+        dest="digest",
+        action="store_true",
+        help="Only digest the email and spit out the generated ID, do not 
archive",
+    )
+    parser.add_argument(
         "--altheader",
         dest="altheader",
         type=str,
@@ -1048,11 +1056,14 @@ def main():
             )
 
             try:
-                lid, mid = archie.archive_message(list_data, msg, raw_message, 
args.dry, args.dump, args.defaultepoch)
-                print(
-                    "%s: Done archiving to %s as %s!"
-                    % (email.utils.formatdate(), lid, mid)
-                )
+                lid, mid = archie.archive_message(list_data, msg, raw_message, 
args.dry, args.dump, args.defaultepoch, args.digest)
+                if args.digest:
+                    print(mid)
+                else:
+                    print(
+                        "%s: Done archiving to %s as %s!"
+                        % (email.utils.formatdate(), lid, mid)
+                    )
             except Exception as err:
                 if args.verbose:
                     traceback.print_exc()

Reply via email to