diff options
Diffstat (limited to 'alot/settings/checks.py')
-rw-r--r-- | alot/settings/checks.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/alot/settings/checks.py b/alot/settings/checks.py new file mode 100644 index 00000000..693d3044 --- /dev/null +++ b/alot/settings/checks.py @@ -0,0 +1,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 |