def __unicode__(self): ''' Generates a text representation of this object. If the L{full_description} returns a useful representation, then the string will have this format:: RemoteTypeName: FullDescriptionString Otherwise, it will resort to the superclass string representation. Example:: Download: The Subways - Staring at the Sun.mp3 [Stopped, 100.0%] ''' nice_name = self.full_description() if nice_name: result = "%s: %s" % (self.get_remote_type(), nice_name) else: result = AzureusObject.__str__(self) try: return unicode(result) # Python 2.2 doesn't define UnicodeDecodeError, we have to use # UnicodeError. except UnicodeError, error: # string_escape only defined in Python 2.3. if sys.version_info >= (2, 3): return unicode(result.encode('string_escape')) else: return unicode(AzureusObject.__str__(self))
def __repr__(self): nice_name = self.short_description() repr_string = AzureusObject.__repr__(self) if nice_name: if repr_string[-1:] == ">": repr_string = repr_string[:-1] + \ ', for "%s">' % nice_name return repr_string