def _build_mpl_wrapper_function_definition(murano_method): def payload(__context, __sender, *args, **kwargs): executor = helpers.get_executor(__context) return murano_method.invoke(executor, __sender, args, kwargs, __context, True) fd = specs.FunctionDefinition(murano_method.name, payload, is_function=False, is_method=True) for i, (name, arg_spec) in enumerate(murano_method.arguments_scheme.iteritems(), 2): p = specs.ParameterDefinition(name, ContractedValue(arg_spec), position=i, default=dsl.NO_VALUE) fd.parameters[name] = p fd.set_parameter( specs.ParameterDefinition('__context', yaqltypes.Context(), 0)) fd.set_parameter( specs.ParameterDefinition( '__sender', yaqltypes.PythonType(dsl_types.MuranoObject, False), 1)) return fd
def _create_basic_mpl_stub(murano_method, reserve_params, payload, check_first_arg): fd = specs.FunctionDefinition( murano_method.name, payload, is_function=False, is_method=True) for i, (name, arg_spec) in enumerate( six.iteritems(murano_method.arguments_scheme), reserve_params + 1): p = specs.ParameterDefinition( name, ContractedValue(arg_spec, with_check=check_first_arg), position=i, default=dsl.NO_VALUE) check_first_arg = False fd.parameters[name] = p fd.set_parameter(specs.ParameterDefinition( '__context', yaqltypes.Context(), 0)) fd.meta[constants.META_MURANO_METHOD] = murano_method return fd
def _create_basic_mpl_stub(murano_method, reserve_params, payload, check_first_arg): fd = specs.FunctionDefinition(murano_method.name, payload, is_function=False, is_method=True) i = reserve_params + 1 varargs = False kwargs = False for name, arg_spec in murano_method.arguments_scheme.items(): position = i if arg_spec.usage == dsl_types.MethodArgumentUsages.VarArgs: name = '*' varargs = True elif arg_spec.usage == dsl_types.MethodArgumentUsages.KwArgs: name = '**' position = None kwargs = True p = specs.ParameterDefinition( name, ContractedValue(arg_spec, with_check=check_first_arg), position=position, default=dsl.NO_VALUE) check_first_arg = False fd.parameters[name] = p i += 1 if not varargs: fd.parameters['*'] = specs.ParameterDefinition( '*', value_type=yaqltypes.PythonType(object, nullable=True), position=i) if not kwargs: fd.parameters['**'] = specs.ParameterDefinition( '**', value_type=yaqltypes.PythonType(object, nullable=True)) fd.set_parameter( specs.ParameterDefinition('__context', yaqltypes.Context(), 0)) fd.meta[constants.META_MURANO_METHOD] = murano_method return fd