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


Python util.unsignedID函数代码示例

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


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

示例1: __str__

	def __str__(self):
		if self._str is not None:
			return self._str
		if hasattr(self, 'func'):
			if hasattr(self.func, 'func_name'):
				func = self.func.func_name
				if hasattr(self.func, 'im_class'):
					func = self.func.im_class.__name__ + '.' + func
			else:
				func = reflect.safe_repr(self.func)
		else:
			func = None
		now = self.seconds()
		L = ['<DelayedCall 0x%x [%ss] called=%s cancelled=%s' % (
				util.unsignedID(self), self.time - now, self.called,
				self.cancelled)]
		if func is not None:
			L.extend((' ', func, '('))
			if self.a:
				L.append(', '.join([reflect.safe_repr(e) for e in self.a]))
				if self.kw:
					L.append(', ')
			if self.kw:
				L.append(', '.join(['%s=%s' % (k, reflect.safe_repr(v)) for (k, v) in self.kw.iteritems()]))
			L.append(')')
		if self.debug:
			L.append('\n\ntraceback at creation: \n\n%s' % ('    '.join(self.creator)))
		L.append('>')
		return ''.join(L)
开发者ID:4ZM,项目名称:cortex-beacon,代码行数:29,代码来源:__init__.py

示例2: __repr__

 def __repr__(self):
     """
     Simple representation with the text.
     """
     s = "<%s at %s, text %r>" % (self.__class__.__name__,
                                  hex(unsignedID(self)), self.text)
     return s
开发者ID:cybergrind,项目名称:twotp,代码行数:7,代码来源:term.py

示例3: __str__

    def __str__(self):
        if self._str is not None:
            return self._str
        if hasattr(self, "func"):
            if hasattr(self.func, "func_name"):
                func = self.func.func_name
                if hasattr(self.func, "im_class"):
                    func = self.func.im_class.__name__ + "." + func
            else:
                func = reflect.safe_repr(self.func)
        else:
            func = None

        now = self.seconds()
        L = [
            "<DelayedCall 0x%x [%ss] called=%s cancelled=%s"
            % (unsignedID(self), self.time - now, self.called, self.cancelled)
        ]
        if func is not None:
            L.extend((" ", func, "("))
            if self.args:
                L.append(", ".join([reflect.safe_repr(e) for e in self.args]))
                if self.kw:
                    L.append(", ")
            if self.kw:
                L.append(", ".join(["%s=%s" % (k, reflect.safe_repr(v)) for (k, v) in self.kw.iteritems()]))
            L.append(")")

        if self.debug:
            L.append("\n\ntraceback at creation: \n\n%s" % ("    ".join(self.creator)))
        L.append(">")

        return "".join(L)
开发者ID:jdb,项目名称:twisted,代码行数:33,代码来源:base.py

示例4: test_unsignedID

    def test_unsignedID(self):
        """
        L{util.unsignedID} uses the function passed to L{util.setIDFunction} to
        determine the unique integer id of an object and then adjusts it to be
        positive if necessary.
        """
        foo = object()
        bar = object()

        # A fake object identity mapping
        objects = {foo: 17, bar: -73}
        def fakeId(obj):
            return objects[obj]

        util.setIDFunction(fakeId)

        self.assertEquals(util.unsignedID(foo), 17)
        self.assertEquals(util.unsignedID(bar), (sys.maxint + 1) * 2 - 73)
开发者ID:P13RR3,项目名称:FrostCore,代码行数:18,代码来源:test_util.py

示例5: _determineClassName

def _determineClassName(x):
    c = _determineClass(x)
    try:
        return c.__name__
    except:
        try:
            return str(c)
        except:
            return '<BROKEN CLASS AT 0x%x>' % unsignedID(c)
开发者ID:GunioRobot,项目名称:twisted,代码行数:9,代码来源:reflect.py

示例6: test_defaultIDFunction

    def test_defaultIDFunction(self):
        """
        L{util.unsignedID} uses the built in L{id} by default.
        """
        obj = object()
        idValue = id(obj)
        if idValue < 0:
            idValue += (sys.maxint + 1) * 2

        self.assertEquals(util.unsignedID(obj), idValue)
开发者ID:P13RR3,项目名称:FrostCore,代码行数:10,代码来源:test_util.py

示例7: _safeFormat

def _safeFormat(formatter, o):
    """
    Helper function for L{safe_repr} and L{safe_str}.
    """
    try:
        return formatter(o)
    except:
        io = StringIO()
        traceback.print_exc(file=io)
        className = _determineClassName(o)
        tbValue = io.getvalue()
        return "<%s instance at 0x%x with %s error:\n %s>" % (
            className, unsignedID(o), formatter.__name__, tbValue)
开发者ID:GunioRobot,项目名称:twisted,代码行数:13,代码来源:reflect.py

示例8: __repr__

    def __repr__(self):
        """
        Return a nice string representation of the Item which contains some
        information about each of its attributes.
        """

        L = [self.__name__]
        L.append('(')
        A = []
        for nam, atr in sorted(self.getSchema()):
            V = atr.reprFor(self)
            A.append('%s=%s' % (nam, V))
        A.append('storeID=' + str(self.storeID))
        L.append(', '.join(A))
        L.append(')')
        L.append('@0x%X' % unsignedID(self))
        return ''.join(L)
开发者ID:bne,项目名称:squeal,代码行数:17,代码来源:item.py

示例9: __repr__

    def __repr__(self):
        """
        Return a nice string representation of the Item which contains some
        information about each of its attributes.
        """

        L = [self.__name__]
        L.append("(")
        A = []
        for nam, atr in sorted(self.getSchema()):
            V = atr.reprFor(self)
            A.append("%s=%s" % (nam, V))
        A.append("storeID=" + str(self.storeID))
        L.append(", ".join(A))
        L.append(")")
        L.append("@0x%X" % unsignedID(self))
        return "".join(L)
开发者ID:mrader11,项目名称:vodafone-mobile-connect,代码行数:17,代码来源:item.py

示例10: __str__

    def __str__(self):
        if self._str is not None:
            return self._str
        if hasattr(self, 'func'):
            # This code should be replaced by a utility function in reflect;
            # see ticket #6066:
            if hasattr(self.func, '__qualname__'):
                func = self.func.__qualname__
            elif hasattr(self.func, '__name__'):
                func = self.func.func_name
                if hasattr(self.func, 'im_class'):
                    func = self.func.im_class.__name__ + '.' + func
            else:
                func = reflect.safe_repr(self.func)
        else:
            func = None

        now = self.seconds()
        L = ["<DelayedCall 0x%x [%ss] called=%s cancelled=%s" % (
                unsignedID(self), self.time - now, self.called,
                self.cancelled)]
        if func is not None:
            L.extend((" ", func, "("))
            if self.args:
                L.append(", ".join([reflect.safe_repr(e) for e in self.args]))
                if self.kw:
                    L.append(", ")
            if self.kw:
                L.append(", ".join(['%s=%s' % (k, reflect.safe_repr(v)) for (k, v) in self.kw.items()]))
            L.append(")")

        if self.debug:
            L.append("\n\ntraceback at creation: \n\n%s" % ('    '.join(self.creator)))
        L.append('>')

        return "".join(L)
开发者ID:hensing,项目名称:twisted,代码行数:36,代码来源:base.py

示例11: __str__

 def __str__(self):
     cname = self.__class__.__name__
     if hasattr(self, 'result'):
         return "<%s at %s  current result: %r>" % (cname, hex(unsignedID(self)),
                                                    self.result)
     return "<%s at %s>" % (cname, hex(unsignedID(self)))
开发者ID:fluidinfo,项目名称:chainDeferredExamples,代码行数:6,代码来源:tdefer.py

示例12: __repr__

 def __repr__(self):
     s = ('<%s to %s at %x>' %
             (self.__class__, self.addr, util.unsignedID(self)))
     return s
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:4,代码来源:tcp.py


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