[mhonarc] output function: kill last option



commit b1baac18b91d586480001a449a68775485cc6dab
Author: Olav Vitters <olav vitters nl>
Date:   Tue Feb 12 22:04:06 2013 +0100

    output function: kill last option

 archive.py |   25 ++++++++-----------------
 1 files changed, 8 insertions(+), 17 deletions(-)
---
diff --git a/archive.py b/archive.py
index 3f5215f..597b992 100755
--- a/archive.py
+++ b/archive.py
@@ -53,11 +53,10 @@ class Archiver:
         self.start_time = None
         self.end_time = None
 
-    def output(self, archivepath, last):
+    def output(self, archivepath):
         if archivepath is None:
             return False
 
-
         tmpname = self.tmpname
 
         path = os.path.join(self.PRIVATE_ARCHIVE_DIR, self.listname, archivepath)
@@ -82,18 +81,6 @@ class Archiver:
         fp.write(open(tmpname, 'rb').read())
         fp.close()
 
-        if last:
-            os.remove(self.tmpname)
-
-            self.make_index(self.listname, self.private)
-
-            # XXX - if public add symlink from private to public
-
-        else:
-            # XXX - reopen tmpname
-            pass
-
-
     def determine_received_time(self, fd):
         """Determines the received time of a message"""
         msg = email.message_from_file(fd)
@@ -141,13 +128,13 @@ class Archiver:
             return archivepath
 
         if archivepath is not None and path is not None and archivepath != path:
-            self.output(archivepath, False)
+            self.output(archivepath)
 
         return path
 
     def process_fd(self, fd):
         """Process a filedescriptor for multiple emails seperated using the mbox format
-        
+
         Calls handle_message for each individual message"""
         _fromlinepattern = (r"From \s*[^\s]+\s+\w\w\w\s+\w\w\w\s+\d?\d\s+"
                             r"\d?\d:\d\d(:\d\d)?(\s+[^\s]+)?\s+\d\d\d\d\s*"
@@ -184,12 +171,16 @@ class Archiver:
         if msg.tell():
             archivepath = self.handle_message(msg, archivepath)
 
-        self.output(archivepath, True)
+        if archivepath:
+            Archiver.make_index(self.listname, self.private)
+
 
     @classmethod
     def make_index(listname, private=False):
         path = os.path.join(self.PRIVATE_ARCHIVE_DIR, listname)
 
+        # XXX - if public add symlink from private to public
+
         dirs = {}
         re_path = re.compile(r'^(\d+)-(\w+)$')
         for a_dir in os.listdir(path):


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