Mercurial > hg > pyloader
changeset 43:a45743b31c6f
set ourselves up to detect circular reference errors
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 08 Jun 2011 18:07:12 -0700 |
parents | 0eebe05f8984 |
children | be4fbf390e36 |
files | pyloader/factory.py |
diffstat | 1 files changed, 20 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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