[Mailman-Users] bin/arch : ctime
Mark Sapiro
mark at msapiro.net
Thu Oct 8 23:30:57 CEST 2009
Rob Lingelbach wrote:
>
>Has anybody ever written a script that would rebuild the html message
>archives that would also modify the file ctime/mtime back to the date
>of the message, as retrieved from the list's mbox file?
This script
-----------------------------------------------------------------------
import os
import re
import time
import os.path
BASE = '/usr/local/mailman/archives/private/listname'
NRE = re.compile(r'^\d+.html$')
DRE = re.compile(r'^\s*<I>([^<]*)</I>\s*$')
def process_file(pname):
for line in open(pname):
mo = DRE.match(line)
if mo:
try:
ptime = time.strptime(mo.group(1),
'%a %b %d %H:%M:%S %Z %Y')
except ValueError:
next
ptime = time.mktime(ptime)
os.utime(pname, (ptime, ptime))
break
for dir, dirnames, filenames in os.walk(BASE):
for fname in filenames:
if NRE.match(fname):
process_file(os.path.join(dir, fname))
-----------------------------------------------------------------------
will change atime and mtime for all the nnnnnn.html files subordinate
to the BASE directory to the time parsed from the line
<I>Day Mmm dd hh:mm:ss TZ yyyy</I>
in the file. It only changes atime and mtime to that time. ctime is
changed to the time that it runs.
--
Mark Sapiro <mark at msapiro.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