changeset 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
files pyloader/factory.py
diffstat 1 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pyloader/factory.py	Thu Jun 09 18:07:39 2011 -0700
+++ b/pyloader/factory.py	Thu Jun 09 18:21:18 2011 -0700
@@ -132,8 +132,10 @@
                 # TODO: could interpolate wrapper 
                 if wrapper in names:
 
-                    # TODO: wrapper arguments:
+                    # inline wrapper arguments:
                     # [extended-fibonacci:@:four=4,five=5:fibonacci]
+                    _wrapper_args = None
+                    _wrapper_kwargs = None
                     if ':' in _path:
                         _wrapper_options, __path = path.split(':', 1)
                         if ',' in _wrapper_options or '=' in _wrapper_options:
@@ -157,7 +159,19 @@
                         if wrapper_section in seen:
                             pass # TODO
                         create_section(wrapper_section, iniconfig[wrapper_section])
-                    wrapper_options = config[wrapper].copy()
+                    wrapper_options = deepcopy(config[wrapper])
+
+                    # add inline wrapper args, kwargs
+                    if _wrapper_args is not None:
+                        if 'args' in wrapper_options:
+                            wrapper_options['args'].extend(_wrapper_args)
+                        else:
+                            wrapper_options['args'] = _wrapper_args
+                    if _wrapper_kwargs is not None:
+                        if 'kwargs' in wrapper_options:
+                            wrapper_options['kwargs'].update(_wrapper_kwargs)
+                        else:
+                            wrapper_options['kwargs'] = _wrapper_kwargs
 
                     # interpolate wrapper_options
                     def interpolate(option):