From d9ffaf4a3b4c13eeaad53bf4b8a6fda48a7eee06 Mon Sep 17 00:00:00 2001 From: Nikolaus Schulz Date: Tue, 13 Nov 2007 00:32:49 +0000 Subject: When converting from other formats to mbox, re-use existing 'Status' and 'X-Status' headers if appropriate (instead of deleting and re-generating them). --- archivemail.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/archivemail.py b/archivemail.py index 252a2aa..ae204cc 100755 --- a/archivemail.py +++ b/archivemail.py @@ -779,7 +779,7 @@ def guess_delivery_time(message): # get more desparate as we go through the array for header in ('Delivery-date', 'Date', 'Resent-Date'): try: - date = message.getdate(header) + date = message.getdate_tz(header) if date: time_message = time.mktime(date) vprint("using valid time found from '%s' header" % header) @@ -853,14 +853,16 @@ def add_status_headers(message): # Overwrite existing 'Status' and 'X-Status' headers. They add no value in # maildirs, and we better don't listen to them. - del message['Status'] if status: vprint("converting maildir status into Status header '%s'" % status) message['Status'] = status - del message['X-Status'] + else: + del message['Status'] if x_status: vprint("converting maildir status into X-Status header '%s'" % x_status) message['X-Status'] = x_status + else: + del message['X-Status'] def add_status_headers_imap(message, flags): """Add Status and X-Status headers to a message from an imap mailbox.""" @@ -884,19 +886,19 @@ def add_status_headers_imap(message, flags): # As with maildir folders, overwrite Status and X-Status headers # if they exist. - del message['Status'] vprint("converting imap status (%s)..." % " ".join(flags)) if status: vprint("generating Status header '%s'" % status) message['Status'] = status else: vprint("not generating Status header") - del message['X-Status'] + del message['Status'] if x_status: vprint("generating X-Status header '%s'" % x_status) message['X-Status'] = x_status else: vprint("not generating X-Status header") + del message['X-Status'] def is_flagged(message): """return true if the message is flagged important, false otherwise""" -- cgit v1.2.3