How to use the yaql.language.specs.ParameterDefinition function in yaql

To help you get started, we’ve selected a few yaql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / murano / murano / dsl / yaql_integration.py View on Github external
def _create_static_mpl_stub(murano_method):
    def payload(__context, __receiver, *args, **kwargs):
        return murano_method.invoke(__receiver, args, kwargs, __context, True)
    fd = _create_basic_mpl_stub(murano_method, 1, payload, False)

    receiver_type = dsl.MuranoTypeParameter(
        weakref.proxy(murano_method.declaring_type), resolve_strings=False)
    fd.set_parameter(specs.ParameterDefinition('__receiver', receiver_type, 1))
    return fd
github openstack / murano / murano / dsl / contracts / contracts.py View on Github external
instance.value = value
            instance.context = context
            instance.__init__(*args, **kwargs)
            return action_func(instance)

        name = yaql_integration.CONVENTION.convert_function_name(cls.name)
        try:
            init_spec = specs.get_function_definition(
                helpers.function(cls.__init__),
                name=name, method=True, convention=yaql_integration.CONVENTION)
        except AttributeError:
            init_spec = specs.get_function_definition(
                lambda self: None,
                name=name, method=True)

        init_spec.parameters['self'] = specs.ParameterDefinition(
            'self', yaqltypes.PythonType(object, nullable=True), 0)
        init_spec.insert_parameter(specs.ParameterDefinition(
            '?1', yaqltypes.Context(), 0))
        init_spec.payload = payload
        return init_spec
github openstack / murano / murano / dsl / contracts / contracts.py View on Github external
instance.__init__(*args, **kwargs)
            return action_func(instance)

        name = yaql_integration.CONVENTION.convert_function_name(cls.name)
        try:
            init_spec = specs.get_function_definition(
                helpers.function(cls.__init__),
                name=name, method=True, convention=yaql_integration.CONVENTION)
        except AttributeError:
            init_spec = specs.get_function_definition(
                lambda self: None,
                name=name, method=True)

        init_spec.parameters['self'] = specs.ParameterDefinition(
            'self', yaqltypes.PythonType(object, nullable=True), 0)
        init_spec.insert_parameter(specs.ParameterDefinition(
            '?1', yaqltypes.Context(), 0))
        init_spec.payload = payload
        return init_spec
github openstack / yaql / yaql / language / specs.py View on Github external
def clone(self):
        return ParameterDefinition(self.name, self.value_type,
                                   self.position, self.alias, self.default)
github openstack / murano / murano / dsl / yaql_integration.py View on Github external
with helpers.contextual(__context):
            __context[constants.CTX_NAMES_SCOPE] = murano_class
            result = helpers.evaluate(cls(*args, **kwargs), __context)
            __receiver.object.extension = result

    try:
        fd = specs.get_function_definition(
            helpers.function(cls.__init__),
            parameter_type_func=lambda name: _infer_parameter_type(
                name, cls.__name__),
            convention=CONVENTION)
    except AttributeError:
        # __init__ is a slot wrapper inherited from object or other C type
        fd = specs.get_function_definition(lambda self: None)
        fd.meta[constants.META_NO_TRACE] = True
    fd.insert_parameter(specs.ParameterDefinition(
        '?1', yaqltypes.Context(), position=0))
    fd.is_method = True
    fd.is_function = False
    fd.name = '__init__'
    fd.payload = payload
    return fd
github openstack / murano / murano / dsl / yaql_integration.py View on Github external
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
github openstack / murano / murano / dsl / yaql_integration.py View on Github external
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
github openstack / murano / murano / dsl / yaql_integration.py View on Github external
def _create_instance_mpl_stub(murano_method):
    def payload(__context, __receiver, *args, **kwargs):
        return murano_method.invoke(__receiver, args, kwargs, __context, True)
    fd = _create_basic_mpl_stub(murano_method, 1, payload, False)

    receiver_type = dsl.MuranoObjectParameter(
        weakref.proxy(murano_method.declaring_type), decorate=False)
    fd.set_parameter(specs.ParameterDefinition('__receiver', receiver_type, 1))
    return fd
github openstack / yaql / yaql / language / specs.py View on Github external
yaql_type = value_type
        p_nullable = nullable
        if value_type is None:
            if p_nullable is None:
                p_nullable = True
            base_type = object \
                if default in (None, NO_DEFAULT, utils.NO_VALUE) \
                else type(default)
            yaql_type = yaqltypes.PythonType(base_type, p_nullable)
        elif not isinstance(value_type, yaqltypes.SmartType):
            if p_nullable is None:
                p_nullable = default is None
            yaql_type = yaqltypes.PythonType(value_type, p_nullable)

        pd = ParameterDefinition(
            name, yaql_type, position, alias, default
        )
        self.parameters[arg_name] = pd
        return pd