aux/convert-mbox-date.py
author Alexander Solovyov <piranha@piranha.org.ua>
Sat, 28 Nov 2009 00:02:29 +0200
changeset 38 83910efdbb54
parent 23 a42b9c661bc1
permissions -rw-r--r--
remove trailing whitespaces
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     1
#!/usr/bin/env python
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     2
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     3
from mercurial.util import parsedate, datestr
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     4
import glob, mailbox
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     5
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     6
issues = glob.glob('.issues/*')
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     7
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     8
for i in issues:
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
     9
	mbox=mailbox.mbox(i)
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    10
	for k in xrange(len(mbox)):
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    11
		msg = mbox[k]
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    12
		print msg['Date']
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    13
		d = parsedate(msg['Date'], ['%a, %d %b %Y %H:%M:%S %Z', '%a, %d %b %Y %H:%M:%S'])
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    14
		print d
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    15
		print datestr(d, '%a, %d %b %Y %H:%M:%S')
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    16
		msg.replace_header('Date', datestr(d, '%a, %d %b %Y %H:%M:%S'))
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    17
		mbox[k] = msg
a42b9c661bc1 Created aux dir with tools to convert from old representations
Dmitriy Morozov <morozov@cs.duke.edu>
parents:
diff changeset
    18
	mbox.flush()