[mhonarc] add remaining command line options



commit 2fc6aa27e0f075e6ed63e82870c4339b46914c4c
Author: Olav Vitters <olav vitters nl>
Date:   Mon Feb 11 22:46:27 2013 +0100

    add remaining command line options

 archive.py |   31 ++++++++++++++++++++++++++++++-
 1 files changed, 30 insertions(+), 1 deletions(-)
---
diff --git a/archive.py b/archive.py
index 207f106..1f7e152 100755
--- a/archive.py
+++ b/archive.py
@@ -5,6 +5,8 @@ import os.path
 import sys
 import gzip
 import argparse
+import time
+import dateutil.parser
 
 
 class Archiver:
@@ -13,6 +15,20 @@ class Archiver:
     PRIVATE_ARCHIVE_DIR = "/var/lib/mailman/archives/private"
     PRIVATE_RCFILE = "/home/admin/mhonarc/private-rc/base.rc"
 
+    MONTHS = {
+        'january':   1,
+        'february':  2,
+        'march':     3,
+        'april':     4,
+        'may':       5,
+        'june':      6,
+        'july':      7,
+        'august':    8,
+        'september': 9,
+        'october':  10,
+        'november': 11,
+        'december': 12
+    }
 
     def __init__(self, listname, private=False, debug=False):
 
@@ -50,7 +66,7 @@ class Archiver:
         if last:
             os.remove(self.tmpname)
 
-            make_index(self.listname, self.private)
+            self.make_index(self.listname, self.private)
 
             # XXX - if public add symlink from private to public
 
@@ -84,6 +100,15 @@ class Archiver:
             self.last_time = received_time
             self.last_parseable_time = received_time_text
 
+    @classmethod
+    def make_index(listname, private=False):
+        path = os.path.join(self.PRIVATE_ARCHIVE_DIR, listname)
+
+
+def mkdate(datestr):
+    #return time.strptime(datestr, '%Y-%m-%d')
+    return dateutil.parser.parse(datestr)
+
 
 def main():
     description = """Archive email using mhonarc from individual files or an Unix mbox."""
@@ -91,6 +116,8 @@ def main():
     parser = argparse.ArgumentParser(description=description,epilog=epilog)
     parser.add_argument('--debug',   action='store_true')
     parser.add_argument('--private', action='store_true')
+    parser.add_argument('--start-time', type=mkdate)
+    parser.add_argument('--end-time', type=mkdate)
     parser.add_argument('--listname')
 
     group = parser.add_mutually_exclusive_group()
@@ -102,6 +129,8 @@ def main():
 
 
     options = parser.parse_args()
+    import pprint
+    pprint.pprint(options)
 
 
 if __name__ == "__main__":


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]