# HG changeset patch # User Jeff Hammel # Date 1305048379 25200 # Node ID 65d9a7c7ac63f0c8b190964cc5616065b951a76d # Parent 6cb7696edc4ddd283e1700a6c836ba0da1bd4692 other misc improvements diff -r 6cb7696edc4d -r 65d9a7c7ac63 pyloader/invoke.py --- a/pyloader/invoke.py Tue May 10 09:28:40 2011 -0700 +++ b/pyloader/invoke.py Tue May 10 10:26:19 2011 -0700 @@ -7,5 +7,17 @@ inspected = obj.__init__ # inspect the ctor argspec = inspect.getargspec(inspected) - - +if __name__ == '__main__': + import sys + from loader import load + from optparse import OptionParser + usage = '%prog Object arg1=value1 arg2=value2 [...]' + description = 'invoke an Object given string arguments' + parser = OptionParser(usage=usage, description=description) + args = sys.argv[1:] + if not args: + parser.print_usage() + parser.exit() + obj_args = dict([i.split('=', 1) for i in args[1:]]) + obj = load(args[0]) + print call(obj, **obj_args) diff -r 6cb7696edc4d -r 65d9a7c7ac63 pyloader/loader.py --- a/pyloader/loader.py Tue May 10 09:28:40 2011 -0700 +++ b/pyloader/loader.py Tue May 10 10:26:19 2011 -0700 @@ -8,6 +8,8 @@ import os import sys +__all__ = ['import_dotted_path', 'load'] + def import_dotted_path(module): path = module.split('.') module = __import__(module)