How to use the yaql.language.specs.parameter 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 / regex.py View on Github external
@specs.parameter('regexp', REGEX_TYPE)
@specs.parameter('string', yaqltypes.String())
@specs.parameter('max_split', int)
@specs.method
def split(regexp, string, max_split=0):
    return regexp.split(string, max_split)
github openstack / yaql / yaql / standard_library / queries.py View on Github external
@specs.parameter('collection', yaqltypes.Iterable())
@specs.parameter('selector', yaqltypes.Lambda())
@specs.method
def select_many(collection, selector):
    """:yaql:selectMany

    Applies a selector to each element of the collection and returns an
    iterator over results. If the selector returns an iterable object,
    iterates over its elements instead of itself.

    :signature: collection.selectMany(selector)
    :receiverArg collection: input collection
    :argType collection: iterable
    :arg selector: function to be applied to every collection element
    :argType selector: lambda
    :returnType: iterator
github openstack / yaql / yaql / standard_library / collections.py View on Github external
@specs.parameter('count', int)
@specs.parameter('values', yaqltypes.Iterable())
def replace_many(collection, position, values, count=1):
    """:yaql:replaceMany

    Returns collection where [position, position+count) elements are replaced
    with values items.

    :signature: collection.replaceMany(position, values, count => 1)
    :receiverArg collection: input collection
    :argType collection: iterable
    :arg position: index to start replace
    :argType position: integer
    :arg values: items to replace
    :argType values: iterable
    :arg count: how many elements to replace, 1 by default
    :argType count: integer
github openstack / yaql / yaql / standard_library / collections.py View on Github external
@specs.parameter('d', utils.MappingType, alias='dict')
@specs.parameter('keys', yaqltypes.Iterable())
def delete_keys_seq(d, keys):
    """:yaql:deleteAll

    Returns dict with keys removed. Keys are provided as an iterable
    collection.

    :signature: dict.deleteAll(keys)
    :receiverArg dict: input dictionary
    :argType dict: mapping
    :arg keys: keys to be removed from dictionary
    :argType keys: iterable
    :returnType: mapping

    .. code::
github openstack / murano / murano / dsl / yaql_functions.py View on Github external
@specs.parameter('object_', dsl.MuranoObjectParameter(decorate=False))
@specs.parameter('func', yaqltypes.Lambda())
def super_(context, object_, func=None):
    cast_type = helpers.get_type(context)
    if func is None:
        return [object_.cast(type) for type in cast_type.parents]
    return map(func, super_(context, object_))
github openstack / yaql / yaql / standard_library / collections.py View on Github external
@specs.parameter('value', nullable=True)
@specs.parameter('position', int)
@specs.name('insert')
def iter_insert(collection, position, value):
    """:yaql:insert

    Returns collection with inserted value at the given position.

    :signature: collection.insert(position, value)
    :receiverArg collection: input collection
    :argType collection: iterable
    :arg position: index for insertion. value is inserted in the end if
        position greater than collection size
    :argType position: integer
    :arg value: value to be inserted
    :argType value: any
    :returnType: iterable
github openstack / yaql / yaql / standard_library / queries.py View on Github external
@specs.parameter('collection', yaqltypes.Iterable())
@specs.method
def single(collection):
    """:yaql:single

    Checks that collection has only one element and returns it. If the
    collection is empty or has more than one element, raises StopIteration.

    :signature: collection.single()
    :receiverArg collection: input collection
    :argType collection: iterable
    :returnType: type of collection's elements

    .. code::

        yaql> ["abc"].single()
        "abc"
github openstack / yaql / yaql / standard_library / common.py View on Github external
@specs.parameter('right', nullable=False)
@specs.name('#operator_>')
def null_gt_right(left, right):
    """:yaql:operator >

    Returns false. This function is called when left is null and right
    is not.

    :signature: left > right
    :arg left: left operand
    :argType left: null
    :arg right: right operand
    :argType right: not null
    :returnType: boolean

    .. code:
github openstack / yaql / yaql / standard_library / math.py View on Github external
@specs.parameter('arg', int)
def bitwise_not(arg):
    return ~arg
github openstack / yaql / yaql / standard_library / collections.py View on Github external
@specs.parameter('left', yaqltypes.Sequence())
@specs.parameter('right', int)
@specs.name('#operator_*')
def list_by_int(left, right, engine):
    """:yaql:operator *

    Returns sequence repeated count times.

    :signature: left * right
    :arg left: input sequence
    :argType left: sequence
    :arg right: multiplier
    :argType right: integer
    :returnType: sequence

    .. code::