Mercurial > hg > pyloader
comparison pyloader/factory.py @ 51:d44f3e6dcffa
interpolate options
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 08 Jun 2011 22:24:32 -0700 |
parents | 12de7b1bf303 |
children | 9bd1a80e8e91 |
comparison
equal
deleted
inserted
replaced
50:12de7b1bf303 | 51:d44f3e6dcffa |
---|---|
131 # TODO: will be correct for | 131 # TODO: will be correct for |
132 # [foo:bar:%(here)s/objects.py:MyClass] | 132 # [foo:bar:%(here)s/objects.py:MyClass] |
133 # but not for | 133 # but not for |
134 # [foo:bar:fleem] | 134 # [foo:bar:fleem] |
135 # in the latter case, just use fleem | 135 # in the latter case, just use fleem |
136 # but check for cyclic consistency | |
136 wrapped_name = section | 137 wrapped_name = section |
137 | 138 |
138 if wrapper not in config: | 139 if wrapper not in config: |
139 wrapper_section = names[wrapper] | 140 wrapper_section = names[wrapper] |
140 if wrapper_section in seen: | 141 if wrapper_section in seen: |
141 pass # TODO | 142 pass # TODO |
142 create_section(wrapper_section, iniconfig[wrapper_section]) | 143 create_section(wrapper_section, iniconfig[wrapper_section]) |
143 wrapper_options = config[wrapper].copy() | 144 wrapper_options = config[wrapper].copy() |
144 | 145 |
145 # TODO interpolate wrapper_options | 146 # TODO interpolate wrapper_options |
147 def interpolate(option): | |
148 return option == object_string and wrapped_name or option | |
146 if 'args' in wrapper_options: | 149 if 'args' in wrapper_options: |
147 args = wrapper_options['args'][:] | 150 args = wrapper_options['args'][:] |
151 args = [interpolate(i) for i in args] | |
148 wrapper_options['args'] = args | 152 wrapper_options['args'] = args |
149 if 'kwargs' in wrapper_options: | 153 if 'kwargs' in wrapper_options: |
150 kwargs = wrapper_options['kwargs'].copy() | 154 kwargs = wrapper_options['kwargs'].copy() |
155 kwargs = dict([(i,interpolate(j)) for i, j in kwargs.items()]) | |
151 wrapper_options['kwargs'] = kwargs | 156 wrapper_options['kwargs'] = kwargs |
157 | |
152 path = _path | 158 path = _path |
153 | 159 |
154 # make a dict for the section | 160 # make a dict for the section |
155 path = path % defaults | 161 path = path % defaults |
156 sect = config[name] = dict(path=path) | 162 sect = config[name] = dict(path=path) |