Пример #1
0
 def testUnsignedID(self):
     util.id = lambda x: x
     try:
         for i in range(1, 100):
             self.assertEquals(util.unsignedID(i), i)
         top = (sys.maxint + 1L) * 2L
         for i in range(-100, -1):
             self.assertEquals(util.unsignedID(i), top + i)
     finally:
         del util.id
Пример #2
0
 def testUnsignedID(self):
     util.id = lambda x: x
     try:
         for i in range(1, 100):
             self.assertEquals(util.unsignedID(i), i)
         top = (sys.maxint + 1L) * 2L
         for i in range(-100, -1):
             self.assertEquals(util.unsignedID(i), top + i)
     finally:
         del util.id
Пример #3
0
 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)
Пример #4
0
	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)
Пример #5
0
    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)
Пример #6
0
 def __repr__(self):
     """
     Simple representation of the data.
     """
     s = "<%s at %s> with value %s" % (self.__class__.__name__,
                                       hex(unsignedID(self)), self.value)
     return s
Пример #7
0
 def __repr__(self):
     """
     Simple representation with the text.
     """
     s = "<%s at %s, text %r>" % (self.__class__.__name__,
                                  hex(unsignedID(self)), self.text)
     return s
Пример #8
0
 def __repr__(self):
     """
     Simple representation with all attributes.
     """
     s = "<%s at %s> named %s, creation %s, id %r" % (
         self.__class__.__name__, hex(unsignedID(self)), self.nodeName,
         self.creation, self.portId)
     return s
Пример #9
0
 def __repr__(self):
     """
     Simple representation with all attributes.
     """
     s = "<%s at %s, named %r, id %s, serial %s, creation %s>" % (
         self.__class__.__name__, hex(unsignedID(self)), self.nodeName,
         self.nodeId, self.serial, self.creation)
     return s
Пример #10
0
 def __repr__(self):
     """
     Simple representation of the data.
     """
     s = "<%s at %s> with data %s, bits %s" % (self.__class__.__name__,
                                               hex(unsignedID(self)),
                                               self.data, self.bits)
     return s
Пример #11
0
 def __repr__(self):
     """
     Simple representation with all attributes.
     """
     s = ("<%s at %s> function %s in module %s, arity %s" % (
         self.__class__.__name__, hex(unsignedID(self)), self.module,
         self.function, self.arity))
     return s
Пример #12
0
def _determineClassName(x):
    c = _determineClass(x)
    try:
        return c.__name__
    except:
        try:
            return str(c)
        except:
            return '<BROKEN CLASS AT 0x%x>' % unsignedID(c)
Пример #13
0
    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)
Пример #14
0
 def __repr__(self):
     """
     Simple representation with all attributes.
     """
     s = ("<%s at %s> with pid %s, module %s, index %s , uniq %s, "
          "freeVars %s" % (
         self.__class__.__name__, hex(unsignedID(self)), self.pid,
         self.module, self.index, self.uniq, self.freeVars))
     return s
    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)
Пример #16
0
    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)
Пример #17
0
    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.assertEqual(util.unsignedID(obj), idValue)
Пример #18
0
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)
Пример #19
0
    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)
Пример #20
0
Файл: item.py Проект: bne/squeal
    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)
Пример #21
0
    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)
Пример #22
0
 def __repr__(self):
     L = [self.__name__]
     L.append('(')
     A = []
     for nam, atr in sorted(self.getSchema()):
         try:
             V = atr.reprFor(self)
         except:
             import traceback
             import sys
             traceback.print_exc(file=sys.stdout)
             V = "<error>"
         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)
Пример #23
0
    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)
Пример #24
0
 def __repr__(self):
     s = ('<%s to %s at %x>' %
             (self.__class__, self.addr, util.unsignedID(self)))
     return s
Пример #25
0
 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)))
Пример #26
0
 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)))
Пример #27
0
 def __repr__(self):
     s = '<%s to %s at %x>' % (self.__class__, self.addr, unsignedID(self))
     return s
Пример #28
0
 def __repr__(self):
     s = "<%s to %s at %x>" % (self.__class__, self.addr, unsignedID(self))
     return s