Mercurial > hg > pyloader
changeset 75:20bdb8125817
inline wrapper arguments now seem to work....thats....uncanny
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Thu, 09 Jun 2011 18:31:13 -0700 |
parents | 1f76705df520 |
children | 1339185cbd2d |
files | pyloader/factory.py tests/objects.py tests/test_ini.txt |
diffstat | 3 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pyloader/factory.py Thu Jun 09 18:21:18 2011 -0700 +++ b/pyloader/factory.py Thu Jun 09 18:31:13 2011 -0700 @@ -137,11 +137,11 @@ _wrapper_args = None _wrapper_kwargs = None if ':' in _path: - _wrapper_options, __path = path.split(':', 1) + _wrapper_options, __path = _path.split(':', 1) if ',' in _wrapper_options or '=' in _wrapper_options: # ,= : tokens to ensure these are wrapper options # as these shouldn't be found in a real path (dotted path or file path) - _wrapper_args, _wrapper_kwargs = factory.str2args(_wrapper_options) + _wrapper_args, _wrapper_kwargs = cast.str2args(_wrapper_options) _path = __path if _path in names:
--- a/tests/objects.py Thu Jun 09 18:21:18 2011 -0700 +++ b/tests/objects.py Thu Jun 09 18:31:13 2011 -0700 @@ -24,7 +24,7 @@ class Wrapper(object): def __init__(self, app, **values): self.app = app - self.values = dict([(int(j), i) for i, j in values]) # TODO: should be automagically converted ideally via pyloader + self.values = dict([(int(j), i) for i, j in values.items()]) # TODO: should be automagically converted ideally via pyloader def __call__(self, *args, **kwargs): retval = self.app(*args, **kwargs) values = {1: 'one',
--- a/tests/test_ini.txt Thu Jun 09 18:21:18 2011 -0700 +++ b/tests/test_ini.txt Thu Jun 09 18:31:13 2011 -0700 @@ -54,3 +54,9 @@ >>> bar = inifactory.load('bar') >>> bar # [1,1,2,3,5,8][5] 8 + +Test inline wrapper arguments, [extended-fibonacci:@:four=4,five=5:fibonacci]:: + + >>> extended = inifactory.load('extended-fibonacci') + >>> [extended(i) for i in range(6)] + ['one', 'one', 'two', 'three', 'five', 8]