How to use the yaql.language.engine.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 / functions / arithmetic.py View on Github external
@parameter('b', custom_validator=_is_a_number)
def divide(a, b):
    if isinstance(a, six.integer_types) and isinstance(b, six.integer_types):
        return a // b
    return a / b
github openstack / yaql / yaql / functions / arithmetic.py View on Github external
@parameter('a', custom_validator=_is_a_number)
@parameter('b', custom_validator=_is_a_number)
def minus(a, b):
    return a - b
github openstack / yaql / yaql / functions / containers.py View on Github external
@parameter('start', arg_type=int)
@parameter('end', arg_type=int)
def _range_limited(start, end):
    for i in six.moves.range(int(start), int(end)):
        yield i
github openstack / yaql / yaql / functions / containers.py View on Github external
def collection_parameter(name):
    return parameter(name, arg_type=collections.Iterable,
                     custom_validator=
                     lambda v: not isinstance(v, six.string_types))
github openstack / yaql / yaql / functions / containers.py View on Github external
@parameter('arg1', lazy=True,
           custom_validator=lambda v: v.key != 'operator_=>')
def build_new_tuple(arg1, arg2):
    return arg1(), arg2
github openstack / yaql / yaql / functions / system.py View on Github external
@parameter('conditions', lazy=True)
def switch(self, *conditions):
    for cond in conditions:
        res = cond(self)
        if not isinstance(res, tuple):
            raise YaqlExecutionException("Switch must have tuple parameters")
        if len(res) != 2:
            raise YaqlExecutionException("Switch tuples must be of size 2")
        if res[0]:
            return res[1]
    return None
github openstack / yaql / yaql / functions / system.py View on Github external
@parameter('att_name', constant_only=True)
@parameter('self', custom_validator=_is_object)
def obj_attribution(self, att_name):
    try:
        return getattr(self, att_name)
    except AttributeError:
        raise YaqlExecutionException("Unable to retrieve object attribute")
github openstack / yaql / yaql / functions / containers.py View on Github external
@parameter('arg1', lazy=True,
           custom_validator=lambda v: v.key == 'operator_=>')
def append_tuple(arg1, arg2):
    res = []
    for tup in arg1():
        res.append(tup)
    res.append(arg2)
    return tuple(res)
github openstack / yaql / yaql / functions / strings.py View on Github external
@parameter('b', arg_type=six.string_types)
def string_concatenation(a, b):
    return a + b
github openstack / yaql / yaql / functions / boolean.py View on Github external
@parameter('b', arg_type=bool)
def _or(a, b):
    return a or b