Python encodings 模块,search_function() 实例源码

我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用encodings.search_function()

项目:Chromium_DepotTools    作者:p07r0457    | 项目源码 | 文件源码
def get_payload(self, index=None, decode=False):
            message = self.message
            if index is None:
                payload = message.get_payload(index, decode)
                if isinstance(payload, list):
                    return [UMessage(msg) for msg in payload]
                if message.get_content_maintype() != 'text':
                    return payload

                charset = message.get_content_charset() or 'iso-8859-1'
                if search_function(charset) is None:
                    charset = 'iso-8859-1'
                return unicode(payload or '', charset, "replace")
            else:
                payload = UMessage(message.get_payload(index, decode))
            return payload
项目:node-gn    作者:Shouqun    | 项目源码 | 文件源码
def get_payload(self, index=None, decode=False):
            message = self.message
            if index is None:
                payload = message.get_payload(index, decode)
                if isinstance(payload, list):
                    return [UMessage(msg) for msg in payload]
                if message.get_content_maintype() != 'text':
                    return payload

                charset = message.get_content_charset() or 'iso-8859-1'
                if search_function(charset) is None:
                    charset = 'iso-8859-1'
                return unicode(payload or '', charset, "replace")
            else:
                payload = UMessage(message.get_payload(index, decode))
            return payload
项目:depot_tools    作者:webrtc-uwp    | 项目源码 | 文件源码
def get_payload(self, index=None, decode=False):
            message = self.message
            if index is None:
                payload = message.get_payload(index, decode)
                if isinstance(payload, list):
                    return [UMessage(msg) for msg in payload]
                if message.get_content_maintype() != 'text':
                    return payload

                charset = message.get_content_charset() or 'iso-8859-1'
                if search_function(charset) is None:
                    charset = 'iso-8859-1'
                return unicode(payload or '', charset, "replace")
            else:
                payload = UMessage(message.get_payload(index, decode))
            return payload
项目:wuye.vim    作者:zhaoyingnan911    | 项目源码 | 文件源码
def get_payload(self, index=None, decode=False):
            message = self.message
            if index is None:
                payload = message.get_payload(index, decode)
                if isinstance(payload, list):
                    return [UMessage(msg) for msg in payload]
                if message.get_content_maintype() != 'text':
                    return payload

                charset = message.get_content_charset() or 'iso-8859-1'
                if search_function(charset) is None:
                    charset = 'iso-8859-1'
                return unicode(payload or '', charset, "replace")
            else:
                payload = UMessage(message.get_payload(index, decode))
            return payload
项目:code    作者:ActiveState    | 项目源码 | 文件源码
def search_function(s):
    if s!="acodec": 
        return None
    u8=encodings.search_function("utf8")
    return codecs.CodecInfo( name='acodec', 
        encode=u8.encode, decode=u8.decode,
        incrementalencoder=u8.incrementalencoder,
        incrementaldecoder=u8.incrementaldecoder,
        streamreader=aStreamReader,        # acodec StreamReader
        streamwriter=u8.streamwriter)
项目:pyxl4    作者:pyxl4    | 项目源码 | 文件源码
def search_function(encoding):
    if encoding != 'pyxl': return None
    # Assume utf8 encoding
    utf8=encodings.search_function('utf8')
    return codecs.CodecInfo(
        name = 'pyxl',
        encode = utf8.encode,
        decode = pyxl_decode,
        incrementalencoder = utf8.incrementalencoder,
        incrementaldecoder = PyxlIncrementalDecoder,
        streamreader = PyxlStreamReader,
        streamwriter = utf8.streamwriter)
项目:pythonql    作者:pythonql    | 项目源码 | 文件源码
def search_function(encoding):
    if encoding != 'pythonql': return None
    # Assume utf8 encoding
    utf8=encodings.search_function('utf8')
    return codecs.CodecInfo(
        name = 'pythonql',
        encode = utf8.encode,
        decode = pythonql_decode,
        incrementalencoder = utf8.incrementalencoder,
        incrementaldecoder = PythonqlIncrementalDecoder,
        streamreader = PythonqlStreamReader,
        streamwriter = utf8.streamwriter)