コード例 #1
0
ファイル: defer.py プロジェクト: TheArchives/blockBox
	def __str__(self):
		"""
		Return a string representation of this C{Deferred}.
		"""
		cname = self.__class__.__name__
		result = getattr(self, 'result', _NO_RESULT)
		myID = hex(unsignedID(self))
		if self._chainedTo is not None:
			result = ' waiting on Deferred at %s' % (hex(unsignedID(self._chainedTo)),)
		elif result is _NO_RESULT:
			result = ''
		else:
			result = ' current result: %r' % (result,)
		return "<%s at %s%s>" % (cname, myID, result)
コード例 #2
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)
コード例 #3
0
ファイル: base.py プロジェクト: katerberg-zz/blockBox
    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)
コード例 #4
0
ファイル: reflect.py プロジェクト: TheArchives/blockBox
def _determineClassName(x):
	c = _determineClass(x)
	try:
		return c.__name__
	except:
		try:
			return str(c)
		except:
			return '<BROKEN CLASS AT 0x%x>' % unsignedID(c)
コード例 #5
0
ファイル: reflect.py プロジェクト: samis/blockBox
def _determineClassName(x):
    c = _determineClass(x)
    try:
        return c.__name__
    except:
        try:
            return str(c)
        except:
            return '<BROKEN CLASS AT 0x%x>' % unsignedID(c)
コード例 #6
0
ファイル: reflect.py プロジェクト: TheArchives/blockBox
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)
コード例 #7
0
ファイル: reflect.py プロジェクト: samis/blockBox
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)
コード例 #8
0
ファイル: tcp.py プロジェクト: TheArchives/blockBox
	def __repr__(self):
		s = ('<%s to %s at %x>' %
				(self.__class__, self.addr, util.unsignedID(self)))
		return s
コード例 #9
0
 def __repr__(self):
     s = ('<%s to %s at %x>' %
          (self.__class__, self.addr, util.unsignedID(self)))
     return s