示例#1
0
    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))
示例#2
0
文件: obj_impl.py 项目: safvan010/123
    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))