How to use the yaql.language.specs.inject 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 / yaql / yaql / standard_library / queries.py View on Github external
@specs.inject('to_list', yaqltypes.Delegate('to_list', method=True))
def split_where(collection, predicate, to_list):
    """:yaql:splitWhere

    Returns collection divided into list of collections where delimiters are
    values for which predicate returns true. Delimiters are deleted from
    result.

    :signature: collection.splitWhere(predicate)
    :receiverArg collection: input collection
    :argType collection: iterable
    :arg predicate: function of one argument to be applied on every
        element. Elements for which predicate returns true are delimiters for
        new list
    :argType predicate: lambda
    :returnType: list
github openstack / yaql / yaql / standard_library / math.py View on Github external
@specs.inject('operator', yaqltypes.Delegate('#operator_>'))
def max_(a, b, operator):
    if operator(b, a):
        return b
    return a
github openstack / murano / murano / dsl / yaql_functions.py View on Github external
@specs.inject('operator', yaqltypes.Super(with_context=True))
@specs.name('#operator_.')
def op_dot_static(context, receiver, expr, operator):
    executor = helpers.get_executor()
    type_context = executor.context_manager.create_type_context(
        receiver.type)
    ctx2 = helpers.link_contexts(context, type_context)
    return operator(ctx2, receiver, expr)
github openstack / yaql / yaql / standard_library / strings.py View on Github external
@specs.inject('str_delegate', yaqltypes.Delegate('str'))
@specs.method
def join_(separator, sequence, str_delegate):
    """:yaql:join

    Returns a string with sequence elements joined by the separator.

    :signature: separator.join(sequence)
    :receiverArg separator: value to be placed between joined pairs
    :argType separator: string
    :arg sequence: chain of values to be joined
    :argType sequence: sequence of strings
    :returnType: string

    .. code::

        yaql> "|".join(["abc", "de", "f"])
github openstack / yaql / yaql / standard_library / legacy.py View on Github external
@specs.inject('delegate', yaqltypes.Super(with_name=True))
@specs.no_kwargs
@specs.extension_method
def dict_(delegate, *tuples):
    """:yaql:dict

    Returns dict built from tuples.

    :signature: dict([args])
    :arg [args]: chain of tuples to be interpreted as (key, value) for dict
    :argType [args]: chain of tuples
    :returnType: dictionary

    .. code::

        yaql> dict(a => 1, b => 2)
        {"a": 1, "b": 2}
github openstack / murano / murano / engine / system / resource_manager.py View on Github external
    @specs.inject('receiver', yaqltypes.Receiver())
    @specs.meta(constants.META_NO_TRACE, True)
    def json(cls, receiver, name, owner=None):
        return jsonlib.loads(cls.string(receiver, name, owner))