当前位置: 首页>>代码示例>>Python>>正文


Python helpers.get_type函数代码示例

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


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

示例1: transform

 def transform(self, value, this, owner, context, default=None):
     if default is None:
         default = self.default
     executor = helpers.get_executor(context)
     if isinstance(this, dsl_types.MuranoType):
         return self._contract.transform(
             value, executor.create_object_context(this),
             None, None, default, helpers.get_type(context))
     else:
         return self._contract.transform(
             value, executor.create_object_context(
                 this.cast(self._container_type())),
             this, owner, default, helpers.get_type(context))
开发者ID:satish-avninetworks,项目名称:murano,代码行数:13,代码来源:typespec.py

示例2: class_

 def class_(value, name, default_name=None, version_spec=None):
     object_store = None if this is None else this.object_store
     if not default_name:
         default_name = name
     murano_class = name.type
     if value is None:
         return None
     if isinstance(value, dsl_types.MuranoObject):
         obj = value
     elif isinstance(value, dsl_types.MuranoObjectInterface):
         obj = value.object
     elif isinstance(value, utils.MappingType):
         obj = helpers.instantiate(
             value, owner, object_store, root_context,
             calling_type, default_name)
     elif isinstance(value, six.string_types) and object_store:
         obj = object_store.get(value)
         if obj is None:
             if not object_store.initializing:
                 raise exceptions.NoObjectFoundError(value)
             else:
                 return TypeScheme.ObjRef(value)
     else:
         raise exceptions.ContractViolationException(
             'Value {0} cannot be represented as class {1}'.format(
                 format_scalar(value), name))
     if not helpers.is_instance_of(
             obj, murano_class.name,
             version_spec or helpers.get_type(root_context)):
         raise exceptions.ContractViolationException(
             'Object of type {0} is not compatible with '
             'requested type {1}'.format(obj.type.name, name))
     return obj
开发者ID:Aqsamm,项目名称:murano,代码行数:33,代码来源:type_scheme.py

示例3: 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

示例4: setAttr

    def setAttr(self, _context, name, value, owner=None):
        if owner is None:
            owner = helpers.get_type(helpers.get_caller_context(_context))
        if not isinstance(owner, murano_class.MuranoClass):
            raise TypeError()

        attribute_store = helpers.get_attribute_store(_context)
        attribute_store.set(self, owner, name, value)
开发者ID:OndrejVojta,项目名称:murano,代码行数:8,代码来源:sys_object.py

示例5: get_attr

    def get_attr(self, this, context, name, default=None, owner=None):
        if owner is None:
            owner = helpers.get_type(helpers.get_caller_context(context))

        attribute_store = helpers.get_attribute_store(context)

        result = attribute_store.get(this.object, owner, name)
        return default if result is None else result
开发者ID:Aqsamm,项目名称:murano,代码行数:8,代码来源:sys_object.py

示例6: _get_package

 def _get_package(owner, receiver):
     if owner is None:
         if isinstance(receiver, dsl_types.MuranoObjectInterface):
             return receiver.extension._package
         murano_class = helpers.get_type(helpers.get_caller_context())
     else:
         murano_class = owner.type
     return murano_class.package
开发者ID:AleptNamrata,项目名称:murano,代码行数:8,代码来源:resource_manager.py

示例7: invoke

 def invoke(context, this, *args):
     try:
         executor = helpers.get_executor(context)
         murano_class = helpers.get_type(context)
         return executor.invoke_method(name, this, context, murano_class, *args)
     except exceptions.NoMethodFound:
         raise yaql.exceptions.YaqlExecutionException()
     except exceptions.AmbiguousMethodName:
         raise yaql.exceptions.YaqlExecutionException()
开发者ID:nastya-kuz,项目名称:murano,代码行数:9,代码来源:yaql_functions.py

示例8: getAttr

    def getAttr(self, _context, name, default=None, owner=None):
        if owner is None:
            owner = helpers.get_type(helpers.get_caller_context(_context))
        if not isinstance(owner, murano_class.MuranoClass):
            raise TypeError()

        attribute_store = helpers.get_attribute_store(_context)

        result = attribute_store.get(self, owner, name)
        return default if result is None else result
开发者ID:OndrejVojta,项目名称:murano,代码行数:10,代码来源:sys_object.py

示例9: _get_container

def _get_container(context, obj, class_name):
    namespace_resolver = helpers.get_type(context).namespace_resolver
    class_loader = helpers.get_class_loader(context)
    class_name = namespace_resolver.resolve_name(class_name)
    murano_class = class_loader.get_class(class_name)
    p = obj.owner
    while p is not None:
        if murano_class.is_compatible(p):
            return p
        p = p.owner
    return None
开发者ID:OndrejVojta,项目名称:murano,代码行数:11,代码来源:yaql_functions.py

示例10: compose_stack_frame

def compose_stack_frame(context):
    instruction = helpers.get_current_instruction(context)
    return {
        'instruction': None if instruction is None
        else str(instruction),

        'location': None if instruction is None
        else instruction.source_file_position,

        'method': helpers.get_current_method(context),
        'class': helpers.get_type(context)
    }
开发者ID:OndrejVojta,项目名称:murano,代码行数:12,代码来源:stack_trace.py

示例11: convert

 def convert(self, value, sender, context, function_spec, engine,
             *args, **kwargs):
     context = self._context or context
     if isinstance(value, yaql_expressions.Expression):
         value = value(utils.NO_VALUE, context, engine)
     value = super(MuranoTypeName, self).convert(
         value, sender, context, function_spec, engine)
     if isinstance(value, types.StringTypes):
         murano_type = helpers.get_type(context)
         value = dsl_types.MuranoClassReference(
             helpers.get_class(
                 murano_type.namespace_resolver.resolve_name(
                     value), context))
     return value
开发者ID:NikolayStarodubtsev,项目名称:murano,代码行数:14,代码来源:dsl.py

示例12: get_property

 def get_property(self, name, 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
     if name in start_type.properties:
         return self.cast(start_type)._get_property_value(name)
     else:
         declared_properties = start_type.find_single_property(name)
         if declared_properties:
             return self.cast(declared_properties).__properties[name]
         elif derived:
             return self.cast(caller_class)._get_property_value(name)
         else:
             raise exceptions.PropertyReadError(name, start_type)
开发者ID:tianshangjun,项目名称:murano,代码行数:15,代码来源:murano_object.py

示例13: convert

 def convert(self, value, sender, context, function_spec, engine,
             *args, **kwargs):
     context = self._context or context
     if isinstance(value, yaql_expressions.Expression):
         value = value(utils.NO_VALUE, context, engine)
     value = super(MuranoTypeName, self).convert(
         value, sender, context, function_spec, engine)
     if isinstance(value, six.string_types):
         if function_spec.meta.get(constants.META_MURANO_METHOD):
             context = helpers.get_caller_context(context)
         murano_type = helpers.get_type(context)
         value = helpers.get_class(
             murano_type.namespace_resolver.resolve_name(value),
             context).get_reference()
     return value
开发者ID:olivierlemasle,项目名称:murano,代码行数:15,代码来源:dsl.py

示例14: check

 def check(self, value, context, *args, **kwargs):
     if not super(MuranoType, self).check(
             value, context, *args, **kwargs):
         return False
     if isinstance(value, MuranoObjectInterface):
         value = value.object
     if value is None or isinstance(value, yaql_expressions.Expression):
         return True
     murano_class = self.murano_class
     if isinstance(murano_class, six.string_types):
         murano_class_name = murano_class
     else:
         murano_class_name = murano_class.name
     return helpers.is_instance_of(
         value, murano_class_name,
         self.version_spec or helpers.get_type(context))
开发者ID:Magic-Mirror,项目名称:murano,代码行数:16,代码来源:dsl.py

示例15: initialize

    def initialize(self, _context, includeNativeFrames=True):
        frames = []
        context = _context
        while True:
            if not context:
                break
            instruction = helpers.get_current_instruction(context)
            frames.append({
                'instruction': None if instruction is None
                else str(instruction),

                'location': None if instruction is None
                else instruction.source_file_position,

                'method': helpers.get_current_method(context),
                'class': helpers.get_type(context)
            })
            context = helpers.get_caller_context(context)
        frames.pop()
        frames.reverse()

        if includeNativeFrames:
            class InstructionStub(object):
                def __init__(self, title, position):
                    self._title = title
                    self.source_file_position = position

                def __str__(self):
                    return self._title

            native_frames = []
            for frame in inspect.trace()[1:]:
                info = inspect.getframeinfo(frame[0])
                position = yaql_expression.YaqlExpressionFilePosition(
                    os.path.abspath(info.filename), info.lineno,
                    -1, -1, -1, -1, -1)
                instruction = InstructionStub(
                    info.code_context[0].strip(), position)
                method = info.function
                native_frames.append({
                    'instruction': instruction,
                    'method': method,
                    'class': None
                })
            frames.extend(native_frames)

        self.set_property('frames', frames)
开发者ID:nastya-kuz,项目名称:murano,代码行数:47,代码来源:stack_trace.py


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