# HG changeset patch # User Jeff Hammel # Date 1307382873 25200 # Node ID e547679d4bfd61da0877a4940dce23ab08100d43 # Parent 8aabb54129a73a8a57752f99820ac36b2aa177ee this now works diff -r 8aabb54129a7 -r e547679d4bfd pyloader/factory.py --- a/pyloader/factory.py Mon Jun 06 09:55:14 2011 -0700 +++ b/pyloader/factory.py Mon Jun 06 10:54:33 2011 -0700 @@ -9,6 +9,7 @@ import os import sys from optparse import OptionParser +from ConfigParser import InterpolationDepthError from ConfigParser import InterpolationMissingOptionError from ConfigParser import InterpolationSyntaxError from ConfigParser import SafeConfigParser as ConfigParser @@ -119,6 +120,7 @@ # make a dict for the section name, path = section.split(':', 1) + path = path % parser.defaults() sect = config[name] = dict(path=path) # read the options @@ -132,7 +134,7 @@ # otherwise, use the raw value try: value = parser.get(section, option) - except (InterpolationMissingOptionError, InterpolationSyntaxError): + except (InterpolationMissingOptionError, InterpolationSyntaxError, InterpolationDepthError): value = parser.get(section, option, raw=True) if option == '.': # positional arguments @@ -144,7 +146,8 @@ def main(args=sys.argv[1:]): """command line entry point""" - parser = OptionParser() + usage = '%prog file1.ini -arg1 -arg2 --key1=value1 --key2=value2' + parser = OptionParser(usage=usage) options, args = parser.parse_args(args) if len(args) != 1: @@ -152,7 +155,8 @@ parser.exit() factory = IniFactory(args[0]) - print factory.load() + obj = factory.load() + print obj if __name__ == '__main__': main()