Mercurial > hg > emaildispatcher
view emaildispatcher/main.py @ 0:bbcc528508f1
initial stub for emaildispatcher framework; ultimately, this should be written in lamson but dont have the patience to learn it today
author | k0s <k0scist@gmail.com> |
---|---|
date | Wed, 30 Dec 2009 22:46:56 -0500 |
parents | |
children | 2c76525ce80b |
line wrap: on
line source
#!/usr/bin/env python import sys from email.Message import Message from optparse import OptionParser from pkg_resources import iter_entry_points def matches_from(message, accept_from): pass def main(args=sys.argv[1:]): parser = OptionParser() parser.add_option('-f', '--file', dest='file', help="file to read from (otherwise use stdin)") parser.add_option('-F', '--from', dest='from', default=[], action='append', help="from addresses to accept") parser.add_option('-H', '--handler', dest='handler', default=None, help="handler to use") parser.add_option('--list-handlers', dest='list_handlers', help="list available handlers") options, args = parser.parse_args(args) vars = dict([arg.split('=, 1) for arg in args if '=' in arg]) args = [arg for arg in args if '=' not in arg] handlers = {} for handler in iter_entry_point('email.dispatchers'): import pdb; pdb.set_trace() if options.from: input = file(options.from).read() else: input = sys.stdin.read() message = Message(input) if __name__ == '__main__': main()