# HG changeset patch # User k0s # Date 1262231216 18000 # Node ID bbcc528508f185fb0f64c7741fdef25c5e9ee083 initial stub for emaildispatcher framework; ultimately, this should be written in lamson but dont have the patience to learn it today diff -r 000000000000 -r bbcc528508f1 emaildispatcher/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emaildispatcher/__init__.py Wed Dec 30 22:46:56 2009 -0500 @@ -0,0 +1,1 @@ +# diff -r 000000000000 -r bbcc528508f1 emaildispatcher/handlers.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emaildispatcher/handlers.py Wed Dec 30 22:46:56 2009 -0500 @@ -0,0 +1,9 @@ +class Images(object): + "extract images from an email message" + + def __init__(self, directory): + self.directory = directory + + def __call__(self, message): + import pdb; pdb.set_trace() + diff -r 000000000000 -r bbcc528508f1 emaildispatcher/main.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/emaildispatcher/main.py Wed Dec 30 22:46:56 2009 -0500 @@ -0,0 +1,42 @@ +#!/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() diff -r 000000000000 -r bbcc528508f1 setup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/setup.py Wed Dec 30 22:46:56 2009 -0500 @@ -0,0 +1,31 @@ +from setuptools import setup, find_packages +import sys, os + +version = '0.0' + +setup(name='emaildispatcher', + version=version, + description='dispatches email to handlers', + long_description="""\ +""", + classifiers=[], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers + keywords='', + author='Jeff Hammel', + author_email='k0scist@gmail.com', + url='http://k0s.org', + license='', + packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), + include_package_data=True, + zip_safe=False, + install_requires=[ + # -*- Extra requirements: -*- + ], + entry_points=""" + # -*- Entry points: -*- + [console_scripts] + emaildispatcher = emaildispatcher.main:main + + [email.dispatchers] + extract_images = emaildispatcher.dispatchers:Images + """, + )