How to use the yaql.language.specs 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 / math.py View on Github external
@specs.parameter('right', yaqltypes.Number())
@specs.name('#operator_/')
def division(left, right):
    if isinstance(left, six.integer_types) and isinstance(
            right, six.integer_types):
        return left // right
    return left / right
github openstack / yaql / yaql / standard_library / yaqlized.py View on Github external
@specs.name('#operator_.')
def op_dot(receiver, expr, context, engine):
    """:yaql:operator .

    Evaluates expression on receiver and returns its result.

    :signature: receiver.expr
    :arg receiver: yaqlized receiver
    :argType receiver: yaqlized object, initialized with
        yaqlize_methods equal to True
    :arg expr: expression to be evaluated
    :argType expr: expression
    :returnType: any (expression return type)
    """
    settings = yaqlization.get_yaqlization_settings(receiver)
    mappings = _remap_name(expr.name, settings)
github openstack / murano / murano / dsl / type_scheme.py View on Github external
        @specs.parameter('value', nullable=True)
        @specs.method
        def int_(value):
            if value is dsl.NO_VALUE:
                value = default
            if value is None:
                return None
            try:
                return int(value)
            except Exception:
                raise exceptions.ContractViolationException(
                    'Value {0} violates int() contract'.format(
                        format_scalar(value)))
github openstack / murano / murano / engine / system / yaql_functions.py View on Github external
@specs.parameter('composer', yaqltypes.Lambda())
@specs.extension_method
def pselect(collection, composer):
    return helpers.parallel_select(collection, composer)
github openstack / murano / murano / dsl / reflection.py View on Github external
@specs.parameter('__object', dsl.MuranoObjectParameter(nullable=True))
@specs.name('invoke')
@specs.method
def method_invoke(context, method, __object, *args, **kwargs):
    return method.invoke(__object, args, kwargs, context)
github openstack / yaql / yaql / standard_library / date_time.py View on Github external
@specs.name('datetime')
@specs.parameter('year', int)
@specs.parameter('month', int)
@specs.parameter('day', int)
@specs.parameter('hour', int)
@specs.parameter('minute', int)
@specs.parameter('second', int)
@specs.parameter('microsecond', int)
@specs.parameter('offset', TIMESPAN_TYPE)
def build_datetime(year, month, day, hour=0, minute=0, second=0,
                   microsecond=0, offset=ZERO_TIMESPAN):
    zone = _get_tz(offset)
    return DATETIME_TYPE(year, month, day, hour, minute, second,
                         microsecond, zone)
github openstack / murano / murano / engine / mock_context_manager.py View on Github external
@specs.parameter('kwargs', yaqltypes.Lambda(with_context=True))
def with_original(context, **kwargs):
    new_context = context.create_child_context()

    original_context = context[constants.CTX_ORIGINAL_CONTEXT]
    for k, v in kwargs.items():
        new_context['$' + k] = v(original_context)
    return new_context
github openstack / yaql / yaql / standard_library / system.py View on Github external
@specs.parameter('name', yaqltypes.StringConstant())
@specs.name('#get_context_data')
def get_context_data(name, context):
    """:yaql:getContextData

    Returns the context value by its name. This function is system
    and can be overridden to change the way of getting context data.

    :signature: getContextData(name)
    :arg name: value's key name
    :argType name: string
    :returnType: any (value type)
    """
    return context[name]
github openstack / yaql / yaql / standard_library / legacy.py View on Github external
@specs.name('#operator_=>')
def build_tuple(left, right, context, engine):
    """:yaql:operator =>

    Returns tuple.

    :signature: left => right
    :arg left: left value for tuple
    :argType left: any
    :arg right: right value for tuple
    :argType right: any
    :returnType: tuple

    .. code::

        yaql> a => b
        ["a", "b"]