[Mailman-Users] Importing Archives Not Working

Mark Sapiro msapiro at value.net
Sat Mar 4 02:43:15 CET 2006


Brad Knowles wrote:

>At 7:40 PM -0500 2006-03-03, Karl Zander wrote:
>
>>  So I have to figure out how to change those date formats.
>>   Anyone know of scripts/tools to manipulate these date
>>  formats?
>
>	See FAQ 3.36.


The method in the FAQ is much more complete than the following, but it
is also more cumbersome if you don't already have formail and procmail
installed.

For a one time Quick and dirty to convert:

   From user at example.com Thu, 01 Dec 2005 15:02:08 -0500

to

   From user at example.com Thu Dec  1 15:02:08 2005

You can try the following:

python script.py <old_mbox >new_mbox

where script.py is between the dashed lines
----------------------------------------------------------
import sys
import time

for line in sys.stdin.readlines():
    if line.startswith('From '):
        fields = line.split()
        date = ' '.join(fields[2:7])
        try:
            t = time.strptime(date, '%a, %d %b %Y %H:%M:%S')
            newtime = time.asctime(t)
            line = ' '.join(fields[0:2] + [newtime] + ['\n'])
        except ValueError:
            pass

    sys.stdout.writelines([line])
----------------------------------------------------------

(I should add this to the FAQ)

-- 
Mark Sapiro <msapiro at value.net>       The highway is for gamblers,
San Francisco Bay Area, California    better use your sense - B. Dylan




More information about the Mailman-Users mailing list