コード例 #1
0
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 six.iteritems(value))
    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(
            evaluate(t, context, freeze)
            for t in yaqlutils.limit_iterable(
                value, constants.ITERATORS_LIMIT))
    elif isinstance(value, dsl_types.MuranoObjectInterface):
        return value.object
    else:
        return value
コード例 #2
0
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(
            evaluate(t, context, freeze) for t in yaqlutils.limit_iterable(
                value, CONF.murano.dsl_iterators_limit))
    elif isinstance(value, dsl_types.MuranoObjectInterface):
        return value.object
    else:
        return value
コード例 #3
0
ファイル: dsl.py プロジェクト: Magic-Mirror/murano
def to_mutable(obj, yaql_engine):
    def converter(value, limit_func, engine, rec):
        if isinstance(value, dsl_types.MuranoObject):
            return MuranoObjectInterface(value)
        else:
            return utils.convert_output_data(value, limit_func, engine, rec)

    limiter = lambda it: utils.limit_iterable(it, constants.ITERATORS_LIMIT)
    return converter(obj, limiter, yaql_engine, converter)
コード例 #4
0
def to_mutable(obj, yaql_engine):
    def converter(value, limit_func, engine, rec):
        if isinstance(value, dsl_types.MuranoObject):
            return MuranoObjectInterface(value)
        else:
            return utils.convert_output_data(value, limit_func, engine, rec)

    limiter = lambda it: utils.limit_iterable(it, constants.ITERATORS_LIMIT)
    return converter(obj, limiter, yaql_engine, converter)
コード例 #5
0
ファイル: dsl.py プロジェクト: starlingx-staging/stx-murano
def to_mutable(obj, yaql_engine=None):
    if yaql_engine is None:
        yaql_engine = helpers.get_yaql_engine()

    def converter(value, limit_func, engine, rec):
        if isinstance(value, dsl_types.MuranoObject):
            return MuranoObjectInterface.create(value)
        else:
            return utils.convert_output_data(value, limit_func, engine, rec)

    limiter = lambda it: utils.limit_iterable(it, CONF.murano.
                                              dsl_iterators_limit)
    return converter(obj, limiter, yaql_engine, converter)
コード例 #6
0
ファイル: helpers.py プロジェクト: olivierlemasle/murano
def evaluate(value, context):
    if isinstance(value, (dsl_types.YaqlExpression, yaql.language.expressions.Statement)):
        return value(context)
    elif isinstance(value, yaqlutils.MappingType):
        return yaqlutils.FrozenDict(
            (evaluate(d_key, context), evaluate(d_value, context)) for d_key, d_value in six.iteritems(value)
        )
    elif yaqlutils.is_sequence(value):
        return tuple(evaluate(t, context) for t in value)
    elif isinstance(value, yaqlutils.SetType):
        return frozenset(evaluate(t, context) for t in value)
    elif yaqlutils.is_iterable(value):
        return tuple(evaluate(t, context) for t in yaqlutils.limit_iterable(value, constants.ITERATORS_LIMIT))
    elif isinstance(value, dsl_types.MuranoObjectInterface):
        return value.object
    else:
        return value
コード例 #7
0
ファイル: helpers.py プロジェクト: satish-avninetworks/murano
def evaluate(value, context):
    if isinstance(value, (dsl_types.YaqlExpression,
                          yaql.language.expressions.Statement)):
        return value(context)
    elif isinstance(value, yaqlutils.MappingType):
        return yaqlutils.FrozenDict(
            (evaluate(d_key, context),
             evaluate(d_value, context))
            for d_key, d_value in six.iteritems(value))
    elif yaqlutils.is_sequence(value):
        return tuple(evaluate(t, context) for t in value)
    elif isinstance(value, yaqlutils.SetType):
        return frozenset(evaluate(t, context) for t in value)
    elif yaqlutils.is_iterable(value):
        return tuple(
            evaluate(t, context)
            for t in yaqlutils.limit_iterable(
                value, constants.ITERATORS_LIMIT))
    elif isinstance(value, dsl_types.MuranoObjectInterface):
        return value.object
    else:
        return value
コード例 #8
0
ファイル: yaqltypes.py プロジェクト: openstack/yaql
 def convert(self, value, receiver, context, function_spec, engine,
             *args, **kwargs):
     res = super(Iterable, self).convert(
         value, receiver, context, function_spec, engine, *args, **kwargs)
     return None if res is None else utils.limit_iterable(res, engine)
コード例 #9
0
def get_limited_if_need(data, engine):
    if (yaqlutils.is_iterable(data) or yaqlutils.is_sequence(data) or
            isinstance(data, (yaqlutils.MappingType, yaqlutils.SetType))):
        return yaqlutils.limit_iterable(data, engine)
    return data
コード例 #10
0
 def convert(self, value, receiver, context, function_spec, engine, *args,
             **kwargs):
     res = super(Iterable,
                 self).convert(value, receiver, context, function_spec,
                               engine, *args, **kwargs)
     return None if res is None else utils.limit_iterable(res, engine)
コード例 #11
0
ファイル: dsl.py プロジェクト: bopopescu/OpenStack-Stein
 def limiter(it):
     return utils.limit_iterable(it, CONF.murano.dsl_iterators_limit)