comparison pyloader/factory.py @ 74:1f76705df520

interpolate inline wrapper options
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 09 Jun 2011 18:21:18 -0700
parents 65c95094dbb3
children 20bdb8125817
comparison
equal deleted inserted replaced
73:65c95094dbb3 74:1f76705df520
130 if ':' in path: 130 if ':' in path:
131 wrapper, _path = path.split(':', 1) 131 wrapper, _path = path.split(':', 1)
132 # TODO: could interpolate wrapper 132 # TODO: could interpolate wrapper
133 if wrapper in names: 133 if wrapper in names:
134 134
135 # TODO: wrapper arguments: 135 # inline wrapper arguments:
136 # [extended-fibonacci:@:four=4,five=5:fibonacci] 136 # [extended-fibonacci:@:four=4,five=5:fibonacci]
137 _wrapper_args = None
138 _wrapper_kwargs = None
137 if ':' in _path: 139 if ':' in _path:
138 _wrapper_options, __path = path.split(':', 1) 140 _wrapper_options, __path = path.split(':', 1)
139 if ',' in _wrapper_options or '=' in _wrapper_options: 141 if ',' in _wrapper_options or '=' in _wrapper_options:
140 # ,= : tokens to ensure these are wrapper options 142 # ,= : tokens to ensure these are wrapper options
141 # as these shouldn't be found in a real path (dotted path or file path) 143 # as these shouldn't be found in a real path (dotted path or file path)
155 # load wrapper configuration 157 # load wrapper configuration
156 wrapper_section = names[wrapper] 158 wrapper_section = names[wrapper]
157 if wrapper_section in seen: 159 if wrapper_section in seen:
158 pass # TODO 160 pass # TODO
159 create_section(wrapper_section, iniconfig[wrapper_section]) 161 create_section(wrapper_section, iniconfig[wrapper_section])
160 wrapper_options = config[wrapper].copy() 162 wrapper_options = deepcopy(config[wrapper])
163
164 # add inline wrapper args, kwargs
165 if _wrapper_args is not None:
166 if 'args' in wrapper_options:
167 wrapper_options['args'].extend(_wrapper_args)
168 else:
169 wrapper_options['args'] = _wrapper_args
170 if _wrapper_kwargs is not None:
171 if 'kwargs' in wrapper_options:
172 wrapper_options['kwargs'].update(_wrapper_kwargs)
173 else:
174 wrapper_options['kwargs'] = _wrapper_kwargs
161 175
162 # interpolate wrapper_options 176 # interpolate wrapper_options
163 def interpolate(option): 177 def interpolate(option):
164 if option == object_string: 178 if option == object_string:
165 return '%(' + wrapped_name + ')s' 179 return '%(' + wrapped_name + ')s'