Example #1
0
    def contextualize(cls, data):
        ctx = {'__vars': data}

        if isinstance(data, dict):
            ctx['__flow'] = ctx['__vars'].get('__flow')
            ctx['__current_task'] = ctx['__vars'].get('__current_task')
            ctx['__current_item'] = ctx['__vars'].get('__current_item')

        for name, func in six.iteritems(cls._custom_functions):
            ctx[name] = functools.partial(func, ctx) if base.func_has_ctx_arg(func) else func

        return ctx
Example #2
0
    def contextualize(cls, data):
        ctx = {"__vars": data}

        if isinstance(data, dict):
            ctx["__state"] = ctx["__vars"].get("__state")
            ctx["__current_task"] = ctx["__vars"].get("__current_task")
            ctx["__current_item"] = ctx["__vars"].get("__current_item")

        for name, func in six.iteritems(cls._custom_functions):
            ctx[name] = functools.partial(func, ctx) if expr_base.func_has_ctx_arg(func) else func

        return ctx
Example #3
0
 def test_inspect_function_has_context_argument(self):
     self.assertTrue(expr_base.func_has_ctx_arg(core_funcs.ctx_))
     self.assertFalse(expr_base.func_has_ctx_arg(core_funcs.json_))
Example #4
0
 def test_inspect_function_has_context_argument(self):
     self.assertTrue(expressions.func_has_ctx_arg(functions.ctx_))
     self.assertFalse(expressions.func_has_ctx_arg(functions.json_))