# HG changeset patch # User Jeff Hammel # Date 1307370817 25200 # Node ID 057ccfe310b27026c3b87c9d48b9287a0d9dfc9c # Parent 8987867698ee1c917242137968e0f2ed037bf3e9 finish basic form of .ini factory - that was easy diff -r 8987867698ee -r 057ccfe310b2 pyloader/factory.py --- a/pyloader/factory.py Mon May 30 10:55:55 2011 -0700 +++ b/pyloader/factory.py Mon Jun 06 07:33:37 2011 -0700 @@ -2,6 +2,7 @@ abstract factories """ +import cast import loader import os from ConfigParser import InterpolationMissingOptionError @@ -107,17 +108,27 @@ # sanity check assert ':' in section, "No : in section: %s" % section + + # make a dict for the section name, path = section.split(':', 1) sect = config[name] = dict(path=path) + + # read the options for option in parser.options(section): if option in parser.defaults(): # don't include the defaults continue + + # try to interpolate the option + # otherwise, use the raw value try: value = parser.get(section, option) except (InterpolationMissingOptionError, InterpolationSyntaxError): value = parser.get(section, option, raw=True) - - + + if option = '.': # positional arguments + sect['args'] = cast.str2list(value) + else: + sect.setdefault('kwargs', {})[option] = value