aux/convert-mbox-maildir.py
author Dmitriy Morozov <morozov@cs.duke.edu>
Wed, 16 Apr 2008 17:25:19 -0400
changeset 23 a42b9c661bc1
parent 21 convert-mbox-maildir.py@5b3579dc7abf
permissions -rw-r--r--
Created aux dir with tools to convert from old representations

import mailbox, glob, os.path, os
import artemis
from mercurial import ui, hg

repo = hg.repository(ui.ui())

issue_filenames = glob.glob(os.path.join(artemis.issues_dir, '*'))
for fn in issue_filenames:
    mb = mailbox.mbox(fn)
    messages = [m for m in mb]
    mb.close()
    os.unlink(fn)
    repo.remove([fn])
    md = mailbox.Maildir(fn)
    md.lock()
    keys = [md.add(m) for m in messages]
    md.close()
    for k in keys: repo.add([fn + '/new/' + k])