• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python helpers.evaluate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中murano.dsl.helpers.evaluate函数的典型用法代码示例。如果您正苦于以下问题:Python evaluate函数的具体用法?Python evaluate怎么用?Python evaluate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了evaluate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _evaluate_parameters

    def _evaluate_parameters(self, arguments_scheme, context, this, *args):
        arg_names = list(arguments_scheme.keys())
        parameter_values = {}
        i = 0
        for arg in args:
            value = helpers.evaluate(arg, context)
            if isinstance(value, types.TupleType) and len(value) == 2 and \
                    isinstance(value[0], types.StringTypes):
                name = value[0]
                value = value[1]
                if name not in arguments_scheme:
                    raise TypeError()
            else:
                if i >= len(arg_names):
                    raise TypeError()
                name = arg_names[i]
                i += 1

            if callable(value):
                value = value()
            arg_spec = arguments_scheme[name]
            parameter_values[name] = arg_spec.validate(
                value, this, None, self._root_context, self._object_store)

        for name, arg_spec in arguments_scheme.iteritems():
            if name not in parameter_values:
                if not arg_spec.has_default:
                    raise TypeError()
                parameter_context = self._create_context(
                    this, this.type, context)
                parameter_values[name] = arg_spec.validate(
                    helpers.evaluate(arg_spec.default, parameter_context),
                    this, None, self._root_context, self._object_store)

        return parameter_values
开发者ID:hybrid-murano,项目名称:hybrid-murano,代码行数:35,代码来源:executor.py


示例2: execute

 def execute(self, context, murano_class):
     if not self.code_block:
         return
     limit = helpers.evaluate(self._limit, context)
     gpool = greenpool.GreenPool(helpers.evaluate(limit, context))
     for expr in self.code_block:
         gpool.spawn_n(expr.execute, context, murano_class)
     gpool.waitall()
开发者ID:OndrejVojta,项目名称:murano,代码行数:8,代码来源:macros.py


示例3: stub

 def stub(*args, **kwargs):
     context = self.context
     args = tuple(helpers.evaluate(arg, context) for arg in args)
     kwargs = dict((key, helpers.evaluate(value, context))
                   for key, value in six.iteritems(kwargs))
     return to_mutable(
         context(item, self.engine, self.sender)(*args, **kwargs),
         self.engine)
开发者ID:Magic-Mirror,项目名称:murano,代码行数:8,代码来源:dsl.py


示例4: __call__

 def __call__(self, __expression, *args, **kwargs):
     context = helpers.get_context().create_child_context()
     for i, param in enumerate(args):
         context['$' + str(i + 1)] = helpers.evaluate(param, context)
     for arg_name, arg_value in six.iteritems(kwargs):
         context['$' + arg_name] = helpers.evaluate(arg_value, context)
     parsed = self.engine(__expression)
     res = parsed.evaluate(context=context)
     return to_mutable(res, self.engine)
开发者ID:Magic-Mirror,项目名称:murano,代码行数:9,代码来源:dsl.py


示例5: execute

 def execute(self, context):
     stacktrace = stack_trace.create_stack_trace(context, False)
     cause = None
     if self._cause:
         cause = helpers.evaluate(self._cause, context).get_property(
             'nativeException')
     raise dsl_exception.MuranoPlException(
         list(self._resolve_names(helpers.evaluate(self._names, context),
                                  context)),
         helpers.evaluate(self._message, context),
         stacktrace, self._extra, cause)
开发者ID:tianshangjun,项目名称:murano,代码行数:11,代码来源:virtual_exceptions.py


示例6: execute

 def execute(self, context, murano_class):
     stacktrace = yaql_functions.new('io.murano.StackTrace', context,
                                     includeNativeFrames=False)
     cause = None
     if self._cause:
         cause = helpers.evaluate(self._cause, context).get_property(
             'nativeException')
     raise dsl_exception.MuranoPlException(
         list(self._resolve_names(helpers.evaluate(self._names, context),
                                  context)),
         helpers.evaluate(self._message, context),
         stacktrace, self._extra, cause)
开发者ID:ddovbii,项目名称:murano,代码行数:12,代码来源:virtual_exceptions.py


示例7: test_evaluate

    def test_evaluate(self):
        yaql_value = mock.Mock(yaql_expression.YaqlExpression,
                               return_value='atom')
        complex_value = {yaql_value: ['some', (1, yaql_value), 'hi!'],
                         'sample': [yaql_value, six.moves.range(5)]}
        complex_literal = utils.FrozenDict({
            'atom': ('some', (1, 'atom'), 'hi!'),
            'sample': ('atom', (0, 1, 2, 3, 4))
        })
        context = yaql.create_context()
        evaluated_value = helpers.evaluate(yaql_value, context)
        evaluated_complex_value = helpers.evaluate(complex_value, context)

        self.assertEqual('atom', evaluated_value)
        self.assertEqual(complex_literal, evaluated_complex_value)
开发者ID:Magic-Mirror,项目名称:murano,代码行数:15,代码来源:test_engine.py


示例8: payload

 def payload(__context, __receiver, *args, **kwargs):
     args = tuple(dsl.to_mutable(arg, engine) for arg in args)
     kwargs = dsl.to_mutable(kwargs, engine)
     with helpers.contextual(__context):
         __context[constants.CTX_NAMES_SCOPE] = \
             murano_class
         return helpers.evaluate(cls(*args, **kwargs), __context)
开发者ID:HarborOS,项目名称:murano,代码行数:7,代码来源:yaql_integration.py


示例9: extension_payload

 def extension_payload(__context, __receiver, *args, **kwargs):
     executor = helpers.get_executor(__context)
     args = tuple(dsl.to_mutable(arg, engine) for arg in args)
     kwargs = dsl.to_mutable(kwargs, engine)
     return helpers.evaluate(murano_method.invoke(
         executor, murano_method.declaring_type,
         (__receiver,) + args, kwargs, __context, True), __context)
开发者ID:HarborOS,项目名称:murano,代码行数:7,代码来源:yaql_integration.py


示例10: set_property

    def set_property(self, name, value, context=None):
        start_type, derived = self.__type, False
        caller_class = None if not context else helpers.get_type(context)
        if caller_class is not None and caller_class.is_compatible(self):
            start_type, derived = caller_class, True
        declared_properties = start_type.find_property(name)
        if context is None:
            context = self.object_store.executor.create_object_context(self)
        if len(declared_properties) > 0:
            declared_properties = self.type.find_property(name)
            values_to_assign = []
            for mc in declared_properties:
                spec = mc.get_property(name)
                if (caller_class is not None and
                        not helpers.are_property_modifications_allowed(context)
                        and (spec.usage not in typespec.PropertyUsages.Writable
                             or not derived)):
                    raise exceptions.NoWriteAccessError(name)

                default = self.__config.get(name, spec.default)
                default = self.__defaults.get(name, default)
                default = helpers.evaluate(default, context)

                obj = self.cast(mc)
                values_to_assign.append((obj, spec.validate(
                    value, self.real_this,
                    self.real_this, default=default)))
            for obj, value in values_to_assign:
                obj.__properties[name] = value
        elif derived:
            obj = self.cast(caller_class)
            obj.__properties[name] = value
        else:
            raise exceptions.PropertyWriteError(name, start_type)
开发者ID:tianshangjun,项目名称:murano,代码行数:34,代码来源:murano_object.py


示例11: execute

 def execute(self, context, murano_class):
     count = helpers.evaluate(self._count, context)
     for t in range(0, count):
         try:
             self._code.execute(context, murano_class)
         except exceptions.BreakException:
             break
开发者ID:nastya-kuz,项目名称:murano,代码行数:7,代码来源:macros.py


示例12: execute

 def execute(self, context):
     match_value = helpers.evaluate(self._value, context)
     for key, value in self._switch.iteritems():
         if key == match_value:
             CodeBlock(value).execute(context)
             return
     if self._default is not None:
         self._default.execute(context)
开发者ID:tianshangjun,项目名称:murano,代码行数:8,代码来源:macros.py


示例13: execute

 def execute(self, context):
     if not self.code_block:
         return
     limit = helpers.evaluate(self._limit, context)
     helpers.parallel_select(
         self.code_block,
         lambda expr: expr.execute(context.create_child_context()),
         limit)
开发者ID:AleptNamrata,项目名称:murano,代码行数:8,代码来源:macros.py


示例14: execute

 def execute(self, context):
     try:
         result = helpers.evaluate(self.expression, context)
         if self.destination:
             self.destination(result, context)
         return result
     except dsl_exception.MuranoPlException:
         raise
     except Exception as e:
         raise dsl_exception.MuranoPlException.from_python_exception(e, context)
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:10,代码来源:expressions.py


示例15: validate

    def validate(self, data, context, default):
        if data is dsl.NO_VALUE:
            data = helpers.evaluate(default, context)

        context = self.prepare_validate_context(context)
        try:
            self._map(data, self._spec, context, '')
            return True
        except exceptions.ContractViolationException:
            return False
开发者ID:Aqsamm,项目名称:murano,代码行数:10,代码来源:type_scheme.py


示例16: __call__

    def __call__(self, data, context, this, owner, default):
        # TODO(ativelkov, slagun): temporary fix, need a better way of handling
        # composite defaults
        # A bug (#1313694) has been filed

        if data is dsl.NO_VALUE:
            data = helpers.evaluate(default, context)

        context = self.prepare_context(context, this, owner, default)
        return self._map(data, self._spec, context)
开发者ID:tianshangjun,项目名称:murano,代码行数:10,代码来源:type_scheme.py


示例17: test_evaluate

    def test_evaluate(self):
        yaql_value = mock.Mock(spec=yaql_expression.YaqlExpression,
                               evaluate=lambda context: 'atom')
        complex_value = {yaql_value: ['some', (1, yaql_value), lambda: 'hi!'],
                         'sample': [yaql_value, xrange(5)]}
        complex_literal = {'atom': ['some', (1, 'atom'), 'hi!'],
                           'sample': ['atom', [0, 1, 2, 3, 4]]}
        # tuple(evaluate(list)) transformation adds + 1
        complex_literal_depth = 3 + 1

        context = yaql.create_context(False)
        evaluated_value = helpers.evaluate(yaql_value, context, 1)
        non_evaluated_value = helpers.evaluate(yaql_value, context, 0)
        evaluated_complex_value = helpers.evaluate(complex_value, context)
        non_evaluated_complex_value = helpers.evaluate(
            complex_value, context, complex_literal_depth)

        self.assertEqual('atom', evaluated_value)
        self.assertNotEqual('atom', non_evaluated_value)
        self.assertEqual(complex_literal, evaluated_complex_value)
        self.assertNotEqual(complex_literal, non_evaluated_complex_value)
开发者ID:OndrejVojta,项目名称:murano,代码行数:21,代码来源:test_engine.py


示例18: __setitem__

 def __setitem__(self, key, value):
     context = helpers.get_context()
     value = helpers.evaluate(value, context)
     self.__object.set_property(key, value, context)
开发者ID:Magic-Mirror,项目名称:murano,代码行数:4,代码来源:dsl.py


示例19: static_payload

 def static_payload(__context, __receiver, *args, **kwargs):
     args = tuple(dsl.to_mutable(arg, engine) for arg in args)
     kwargs = dsl.to_mutable(kwargs, engine)
     return helpers.evaluate(murano_method.invoke(
         __receiver, args, kwargs, __context, True), __context)
开发者ID:AleptNamrata,项目名称:murano,代码行数:5,代码来源:yaql_integration.py


示例20: _finalize

def _finalize(obj, context):
    return helpers.evaluate(obj, context)
开发者ID:olivierlemasle,项目名称:murano,代码行数:2,代码来源:yaql_integration.py



注:本文中的murano.dsl.helpers.evaluate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python helpers.get_executor函数代码示例发布时间:2022-05-27
下一篇:
Python session.get_session函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap