def convert(mbx, embedded_dir=None, opts=None): """ Start at the Eudora specific pattern "^From ???@???" and keep gathering all headers. When an empty line is found, emit the headers. Replace ???@??? with the e-mail address in "From: " (if found), or else use "Sender: " or else "Return-Path: " or else use the magic address "*****@*****.**" for later analysis (easily greppable). Also add a "Date: " if missing (mostly for outbound mail sent by yourself) which is extracted from the Eudora "From ???@??? ..." line, but is reformatted, because Eudora has the order in the datum items wrong. Eudora uses: dayname-abbr monthname-abbr monthnumber-nn time-hh:mm:ss year-yyyy whereas it should be: dayname-abbr monthnumber-nn monthname-abbr year-yyyy time-hh:mm:ss Example: Thu 03 Jan 2002 11:42:42 (24 characters) """ global attachments_listed, attachments_found, attachments_missing, attachments_dirs global paths_found, paths_missing, message_count global re_initial_whitespace global toc_info, replies, target global edir attachments_listed = 0 attachments_found = 0 attachments_missing = 0 edir = embedded_dir print "Converting %s" % (mbx, ) if not mbx: EudoraLog.fatal(P + ': usage: Eudora2Mbox.py eudora-mailbox-file.mbx') return 0 attachments_dirs = [] target = '' format = None if opts: for f, v in opts: if f == '-a': attachments_dirs = v.split(':') elif f == '-f': format = v.strip().lower() elif f == '-t': target = v EudoraLog.log = EudoraLog.Log(mbx) try: INPUT = open(mbx, 'r') except IOError, (errno, strerror): INPUT = None return EudoraLog.fatal(P + ': cannot open "' + mbx + '", ' + strerror)