How to use the yaql.language.utils.NO_VALUE 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 / helpers.py View on Github external
def patch_dict(dct, path, value):
    parts = path.split('.')
    for i in range(len(parts) - 1):
        if not isinstance(dct, dict):
            dct = None
            break
        dct = dct.get(parts[i])
    if isinstance(dct, dict):
        if value is yaqlutils.NO_VALUE:
            dct.pop(parts[-1])
        else:
            dct[parts[-1]] = value
github openstack / yaql / yaql / language / contexts.py View on Github external
def get_data(self, name, default=None, ask_parent=True):
        for context in self._context_list:
            result = context.get_data(name, utils.NO_VALUE, False)
            if result is not utils.NO_VALUE:
                return result
        ctx = self.parent
        while ask_parent and ctx:
            result = ctx.get_data(name, utils.NO_VALUE, False)
            if result is utils.NO_VALUE:
                ctx = ctx.parent
            else:
                return result
        return default
github openstack / yaql / yaql / language / expressions.py View on Github external
def evaluate(self, data=utils.NO_VALUE, context=None):
        if context is None or context is utils.NO_VALUE:
            context = yaql.create_context()
        if data is not utils.NO_VALUE:
            if self.engine.options.get('yaql.convertInputData', True):
                context['$'] = utils.convert_input_data(data)
            else:
                context['$'] = data
        return self(utils.NO_VALUE, context, self.engine)
github openstack / murano / murano / dsl / dsl.py View on Github external
def implementation(ctx=None):
            value2 = value
            if ctx is None:
                ctx = self._context or context
            if isinstance(value2, yaql_expressions.Expression):
                value2 = value2(utils.NO_VALUE, ctx, engine)
            value2 = super(MuranoTypeParameter, self).convert(
                value2, sender, ctx, function_spec, engine)
            if isinstance(value2, str):
                value2 = helpers.get_class(value2, ctx).get_reference()
            if self._base_type and not self._base_type.is_compatible(value):
                raise ValueError('Value must be subtype of {0}'.format(
                    self._base_type.name
                ))
            return value2
github openstack / yaql / yaql / standard_library / queries.py View on Github external
.. code::

        yaql> [0, 1, 2].last()
        2
    """
    if isinstance(collection, utils.SequenceType):
        if len(collection) == 0:
            if default is utils.NO_VALUE:
                raise StopIteration()
            else:
                return default
        return collection[-1]
    last_value = default
    for t in collection:
        last_value = t
    if last_value is utils.NO_VALUE:
        raise StopIteration()
    else:
        return last_value
github openstack / yaql / yaql / language / contexts.py View on Github external
    def __call__(self, name, engine, receiver=utils.NO_VALUE,
                 data_context=None, use_convention=False,
                 function_filter=None):
        return lambda *args, **kwargs: runner.call(
            name, self, args, kwargs, engine, receiver,
            data_context, use_convention, function_filter)
github openstack / yaql / yaql / language / contexts.py View on Github external
def get_data(self, name, default=None, ask_parent=True):
        result = self.linked_context.get_data(
            name, default=utils.NO_VALUE, ask_parent=False)
        if result is utils.NO_VALUE:
            if not ask_parent or not self.parent:
                return default
            return self.parent.get_data(name, default=default, ask_parent=True)
        return result
github openstack / yaql / yaql / language / contexts.py View on Github external
    def __init__(self, parent_context=None, data=utils.NO_VALUE,
                 convention=None):
        super(Context, self).__init__(parent_context, convention)
        self._functions = {}
        self._data = {}
        self._exclusive_funcs = set()
        if data is not utils.NO_VALUE:
            self['$'] = data
github openstack / yaql / yaql / language / runner.py View on Github external
arg_evaluator = lambda i, arg: (  # noqa: E731
        arg(utils.NO_VALUE, context, engine)
        if (i not in lazy_params and isinstance(arg, expressions.Expression)
            and not isinstance(arg, expressions.Constant))
        else arg
    )
github openstack / yaql / yaql / language / contexts.py View on Github external
def get_data(self, name, default=None, ask_parent=True):
        for context in self._context_list:
            result = context.get_data(name, utils.NO_VALUE, False)
            if result is not utils.NO_VALUE:
                return result
        ctx = self.parent
        while ask_parent and ctx:
            result = ctx.get_data(name, utils.NO_VALUE, False)
            if result is utils.NO_VALUE:
                ctx = ctx.parent
            else:
                return result
        return default