# HG changeset patch # User Jeff Hammel # Date 1307581632 25200 # Node ID a45743b31c6fb9197d1f94a68d9003bf55da7283 # Parent 0eebe05f898493b783a5c299fed8d0faa29b075c set ourselves up to detect circular reference errors diff -r 0eebe05f8984 -r a45743b31c6f pyloader/factory.py --- a/pyloader/factory.py Wed Jun 08 17:52:41 2011 -0700 +++ b/pyloader/factory.py Wed Jun 08 18:07:12 2011 -0700 @@ -103,13 +103,25 @@ def configuration(cls, iniconfig, **defaults): """interpret configuration from raw .ini syntax""" config = {} - for section, options in iniconfig.items(): + interpolated = set() + seen = set() + + def create_section(section, options): # sanity check assert ':' in section, "No : in section: %s" % section # make a dict for the section name, path = section.split(':', 1) + + # interpret decorators + if ':' in path: + wrapper, _path = path.split(':', 1) + # TODO: could interpolate wrapper + if wrapper in iniconfig: + + path = _path + path = path % defaults sect = config[name] = dict(path=path) @@ -119,6 +131,13 @@ sect['args'] = cast.str2list(value) else: sect.setdefault('kwargs', {})[option] = value + + + for section, options in iniconfig.items(): + seen.add(section) + if section not in interpolated: + create_section(section, options) + interpolated.add(section) return config