How to use the yaql.language.utils.FrozenDict 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 / lhs_expression.py View on Github external
def setter(src_property, value):
            src = src_property.get()
            if isinstance(src, utils.MappingType):
                src_property.set(
                    utils.FrozenDict(
                        itertools.chain(
                            src.items(),
                            ((key, value),))))
            elif isinstance(src, dsl_types.MuranoObject):
                src.set_property(key, value, context['#root_context'])
            elif isinstance(src, (
                    dsl_types.MuranoTypeReference,
                    dsl_types.MuranoType)):
                if isinstance(src, dsl_types.MuranoTypeReference):
                    mc = src.type
                else:
                    mc = src
                helpers.get_executor().set_static_property(
                    mc, key, value, context['#root_context'])
            else:
                raise ValueError(
github openstack / murano / murano / policy / modify / actions / default_actions.py View on Github external
elif isinstance(val, tuple):
                    filtered_list = list(val)
                    for item in val:
                        if self._match_object_id(self._object_id, item):
                            filtered_list.remove(item)
                    if len(filtered_list) < len(val):
                        _obj.set_property(prop_name, tuple(filtered_list))
                # remove object from dict
                elif isinstance(val, utils.FrozenDict):
                    filtered_dict = {k: v for k, v in val.items() if not
                                     self._match_object_id(self._object_id,
                                                           k) and not
                                     self._match_object_id(self._object_id, v)}
                    if len(filtered_dict) < len(val):
                        _obj.set_property(prop_name,
                                          utils.FrozenDict(filtered_dict))
github openstack / yaql / yaql / language / factory.py View on Github external
def __init__(self, ply_lexer, ply_parser, options, factory):
        self._lexer = ply_lexer
        self._parser = ply_parser
        self._options = utils.FrozenDict(options or {})
        self._factory = factory
github openstack / murano / murano / dsl / type_scheme.py View on Github external
else:
                result[key] = self._map(
                    data.get(key), value, context, '{0}[{1}]'.format(
                        path, format_scalar(key)))

        if yaql_key is not None:
            yaql_value = spec[yaql_key]
            for key, value in six.iteritems(data):
                if key in result:
                    continue
                key = self._map(key, yaql_key, context, path)
                result[key] = self._map(
                    value, yaql_value, context, '{0}[{1}]'.format(
                        path, format_scalar(key)))

        return utils.FrozenDict(result)
github openstack / murano / murano / dsl / helpers.py View on Github external
def evaluate(value, context, freeze=True):
    list_type = tuple if freeze else list
    dict_type = yaqlutils.FrozenDict if freeze else dict
    set_type = frozenset if freeze else set

    if isinstance(value, (dsl_types.YaqlExpression,
                          yaql.language.expressions.Statement)):
        return value(context)
    elif isinstance(value, yaqlutils.MappingType):
        return dict_type(
            (evaluate(d_key, context, freeze),
             evaluate(d_value, context, freeze))
            for d_key, d_value in value.items())
    elif yaqlutils.is_sequence(value):
        return list_type(evaluate(t, context, freeze) for t in value)
    elif isinstance(value, yaqlutils.SetType):
        return set_type(evaluate(t, context, freeze) for t in value)
    elif yaqlutils.is_iterable(value):
        return list_type(
github openstack / yaql / yaql / standard_library / collections.py View on Github external
:argType dict: dictionary
    :arg key: key
    :argType key: keyword
    :arg value: value to be set to input key
    :argType value: any
    :returnType: dictionary

    .. code::

        yaql> {"a" => 1, "b" => 2}.set("c", 3)
        {"a": 1, "b": 2, "c": 3}
        yaql> {"a" => 1, "b" => 2}.set("b", 3)
        {"a": 1, "b": 3}
    """
    utils.limit_memory_usage(engine, (1, d), (1, key), (1, value))
    return utils.FrozenDict(itertools.chain(six.iteritems(d), ((key, value),)))
github openstack / yaql / yaql / standard_library / collections.py View on Github external
Returns dict with replacements keys set to replacements values.

    :signature: dict.set(replacements)
    :receiverArg dict: input dictionary
    :argType dict: dictionary
    :arg replacements: mapping with keys and values to be set on input dict
    :argType key: dictionary
    :returnType: dictionary

    .. code::

        yaql> {"a" => 1, "b" => 2}.set({"b" => 3, "c" => 4})
        {"a": 1, "c": 4, "b": 3}
    """
    utils.limit_memory_usage(engine, (1, d), (1, replacements))
    return utils.FrozenDict(itertools.chain(
        six.iteritems(d), six.iteritems(replacements)))