Bug in rfc822

Emmanuel Jeandel ejeandel at ens-lyon.fr
Wed Jul 11 10:31:01 EDT 2001


If someone is playing with rfc822, i'm interested !

I'm writing a small script that does statistics about mailboxes :
it writes for each sender (respectively receiver) the number of mail
he sends to you (resp. receives from you), and the total size of mails,
size  meaning : i drop all html code, attachments (I use multifile
to consider only the first part of a message) and 
drop all lines beginning with '>' . If someone
is interested the program can be located in 
http://www.ens-lyon.fr/~ejeandel/mailstat
(python 1.5, but I think it is 2.0 compliant)
syntax: mailstat r namesofthemailboxes for parsing inboxes
        mailstat w .... for parsing outboxes
you can also use mailstat r20 to parse only the mail from the last 20 days
(I know that the parsing of the command line is very weak, but i don't
want to lose my time doing this in a more pretty way)

Playing with rfc822 is good, but i think mailbox.py has also several
problems. When you do mailbox.next(), the function return a rfc822.Message
but i wanted to use my class MyMessage, so i have to rewrite : 

class MyUnixMailbox(mailbox.UnixMailbox):
    def next(self):
        while 1:
            self.fp.seek(self.seekp)
            try:
    	        self._search_start()
	    except EOFError:
  	        self.seekp = self.fp.tell()
	        return None
	    start = self.fp.tell()
	    self._search_end()
	    self.seekp = stop = self.fp.tell()
	    if start <> stop:
	        break
	return MyMessage(mailbox._Subfile(self.fp, start, stop))

Do you know of any prettier solution ?

Thanks in advance
Emmanuel





More information about the Python-list mailing list