Pipermail -> Netscape
Christian Tismer
tismer at tismer.com
Tue Mar 21 10:33:17 EST 2000
Howdy,
today I had to grab a pipermail archive and include it
as a netscape folder. This works fine, but the "From:"
fields are not as nice as they could be.
So I wrote the attached script. Maybe it is of use for somebody.
Usage:
Grab a pipermail file
run the repair_from() function on it
Quit Netscape
Drop the modified file somewhere between Netscape's mail files
Rename it to something without extension, like "patches-feb"
Start Netscape, find your new folder and enjoy.
ciao - chris
the veery complicated script
--- piperep.py ----------------------------------------
"""
regenerate email addresses from pipermail archives
ct y2k0321
Problem: Email headers appear as such:
'From: Andrew M. Kuchling akuchlin at mems-exchange.org'
while it should be
'From: "Andrew M. Kuchling" <akuchlin at mems-exchange.org>'
for Netscape.
"""
import string
def repair_from(fname):
txt = open(fname, "r").readlines()
new = []
for line in txt:
if line[:6]=="From: ":
words = string.split(line)
if len(words) > 2 and words[1][0] != '"':
pre, mid, adr = words[0], words[1:-1], words[-1]
mid = '"%s"' % string.join(mid)
adr = '<%s>\n' % adr
line = string.join([pre, mid, adr])
new.append(line)
open(fname, "w").writelines(new)
-------------------------------------------------------
--
Christian Tismer :^) <mailto:tismer at appliedbiometrics.com>
Applied Biometrics GmbH : Have a break! Take a ride on Python's
Kaunstr. 26 : *Starship* http://starship.python.net
14163 Berlin : PGP key -> http://wwwkeys.pgp.net
PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF
we're tired of banana software - shipped green, ripens at home
More information about the Python-list
mailing list