blob: 693d30443597f4ee8b627fee04de334f63bade5a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import mailbox
import re
from urlparse import urlparse
def mail_container(value):
if not re.match(r'.*://.*', value):
raise VdtTypeError(value)
mburl = urlparse(value)
if mburl.scheme == 'mbox':
box = mailbox.mbox(mburl.path)
elif mburl.scheme == 'maildir':
box = mailbox.Maildir(mburl.path)
elif mburl.scheme == 'mh':
box = mailbox.MH(mburl.path)
elif mburl.scheme == 'babyl':
box = mailbox.Babyl(mburl.path)
elif mburl.scheme == 'mmdf':
box = mailbox.MMDF(mburl.path)
else:
raise VdtTypeError(value)
return box
|