From 16999ce35b2d63a9e611aa45000e12d28889dd69 Mon Sep 17 00:00:00 2001 From: Paul Rodger Date: Wed, 3 Apr 2002 11:12:25 +0000 Subject: Don't assume we will always have a Delivery-Date header when constructing the 'From_' line from a 'maildir' folder. Use the 'Date' header when we dont. --- archivemail.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/archivemail.py b/archivemail.py index db090dc..948c116 100755 --- a/archivemail.py +++ b/archivemail.py @@ -582,19 +582,30 @@ def make_mbox_from(message): vprint("make_mbox_from: no Return-path -- using 'From:' instead!") address_header = message.get('From') (name, address) = rfc822.parseaddr(address_header) - date = rfc822.parsedate(message.get('Delivery-date')) + + date = None + delivery_date_header = message.get('Delivery-date') + if delivery_date_header: + date = rfc822.parsedate(delivery_date_header) if not date: - date = rfc822.parsedate(message.get('Date')) + date_header = message.get('Date') + if not date_header: + unexpected_error("message has no 'Date' header") + date = rfc822.parsedate(date_header) + if not date: + unexpected_error("message has no valid 'Date' header") date_string = time.asctime(date) mbox_from = "From %s %s\n" % (address, date_string) return mbox_from + def get_date_mtime(message): """Return the delivery date of an rfc822 message in a maildir mailbox""" assert(message) vprint("using last-modification time of message file") return os.path.getmtime(message.fp.name) + def get_date_headers(message): """Return the delivery date of an rfc822 message in a mbox mailbox""" assert(message) -- cgit v1.2.3