mbx repair script: Python vs perl

Donn Cave donn at drizzle.com
Sat Apr 30 12:18:49 EDT 2005


Quoth "David Isaac" <aisaac0 at verizon.net>:
| I'm looking for the Python equivalent of the perl script and module
| described at
| http://comments.gmane.org/gmane.mail.imap.uw.c-client/707
|
| Any hope?

Sure, should be doable, if for some reason you can't just use that.
I personally wouldn't do it exactly that way, rather I would just
read the file directly.

At first you said you were only interested in fixing the header.
This one operates on the rest of the file, and I guess I will assume
that's what you really want.  MBX structure is just a one line message
header before each message, with a message size value among other things.
Readers of this format will add that size value to the current file
offset and expect another header line at that point.  When the data
there isn't a valid header line, they die.  One does not need the
c-client library to do this, but more to the point it isn't what you
want to do, with a damaged file.

Just read the file from one end to the other and find everything that
looks like a header line, and then rewrite the file with adjusted header
lines required so that

- they are in ascending order by ID number
- they have correct sizes.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list