mailbox.py - bug or my fault?

Klaus Meyer km-news1 at onlinehome.de
Thu May 15 17:32:03 EDT 2003


Hello,

this little script reads a Mbox-File and writes a new Mbox-File with all 
Messages.

But the new file "test.mbx" is not equal, because many of the headers 
scrambled like:

Original:
>From h at h.de Wed Jan 22 23:51:25 2003
Return-Path: <heiko at hmol.de>

Copy:
>From h at h.de WReturn-Path: <heiko at hmol.de>

or

Original:
>From k at g.de Wed Jan 22 23:51:41 2003
X-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000

Copy:
>From k at g.de Wed JanX-Mozilla-Status: 0001
X-Mozilla-Status2: 00000000


A known bug in mailbox or something else wrong?


#win2k, Python 2.2.2
import mailbox

fpi = open(r"C:\in.mbx")
fpo = open(r"C:\test.mbx", "w")
mb = mailbox.PortableUnixMailbox(fpi)

for msg in mb:
    fpo.writelines(msg.headers)     #alle Header
    fpo.write("\n")                 #Leerzeile nach Header erzeugen
    fpo.write(msg.fp.read())        #Body

fpi.close()
fpo.close()

(I tried also fpo.flush() and fpo.write(msg.unixfrom), does not help)

-- 
Gruß - regards Klaus :-)




More information about the Python-list mailing list