properties.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:core-framework 作者: RedhawkSDR 项目源码 文件源码
def query(self, obj, operator=None):
        # Get the complete current value via the base class interface.
        value = self._query(obj)
        if value is None:
            return any.to_any(value)

        # Don't apply an operator if the value is already a CORBA Any, which
        # should only occur in the case of a (legacy) user callback.
        if isinstance(value, CORBA.Any):
            return value

        # Attempt to apply the operator to the returned value.
        try:
            if operator in ("[]", "[*]"):
                value = self._getDefaultOperator(value, operator)
            elif operator == "[?]":
                value = self._getKeysOperator(value, operator)
                return any.to_any(check_type_for_long(value))
            elif operator == "[@]":
                value = self._getKeyValuePairsOperator(value, operator)
                return any.to_any(check_type_for_long(value))
            elif operator == "[#]":
                value = len(self._getDefaultOperator(value, operator))
                return any.to_any(check_type_for_long(value))
            elif operator != None:
                value = self._getSliceOperator(value, operator)
        except Exception, e:
            raise AttributeError, "error processing operator '%s': '%s' %s" % (operator, e, "\n".join(traceback.format_tb(sys.exc_traceback)))

        # At this point, value must be a normal sequence, so we can use the
        # standard conversion routine.
        return self._toAny(value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号