当前位置: 首页>>代码示例>>Python>>正文


Python quopri.encode方法代码示例

本文整理汇总了Python中quopri.encode方法的典型用法代码示例。如果您正苦于以下问题:Python quopri.encode方法的具体用法?Python quopri.encode怎么用?Python quopri.encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在quopri的用法示例。


在下文中一共展示了quopri.encode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: encode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def encode(input, output, encoding):
    """Encode common content-transfer-encodings (base64, quopri, uuencode)."""
    if encoding == 'base64':
        import base64
        return base64.encode(input, output)
    if encoding == 'quoted-printable':
        import quopri
        return quopri.encode(input, output, 0)
    if encoding in ('uuencode', 'x-uuencode', 'uue', 'x-uue'):
        import uu
        return uu.encode(input, output)
    if encoding in ('7bit', '8bit'):
        return output.write(input.read())
    if encoding in encodetab:
        pipethrough(input, encodetab[encoding], output)
    else:
        raise ValueError, \
              'unknown Content-Transfer-Encoding: %s' % encoding

# The following is no longer used for standard encodings

# XXX This requires that uudecode and mmencode are in $PATH 
开发者ID:glmcdona,项目名称:meddle,代码行数:24,代码来源:mimetools.py

示例2: quopri_encode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def quopri_encode(input, errors='strict'):
    """Encode the input, returning a tuple (output object, length consumed).

    errors defines the error handling to apply. It defaults to
    'strict' handling which is the only currently supported
    error handling for this codec.

    """
    assert errors == 'strict'
    # using str() because of cStringIO's Unicode undesired Unicode behavior.
    f = StringIO(str(input))
    g = StringIO()
    quopri.encode(f, g, 1)
    output = g.getvalue()
    return (output, len(input)) 
开发者ID:glmcdona,项目名称:meddle,代码行数:17,代码来源:quopri_codec.py

示例3: encode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def encode(self, input,errors='strict'):
        return quopri_encode(input,errors) 
开发者ID:glmcdona,项目名称:meddle,代码行数:4,代码来源:quopri_codec.py

示例4: getregentry

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
    ) 
开发者ID:glmcdona,项目名称:meddle,代码行数:12,代码来源:quopri_codec.py

示例5: quopri_encode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def quopri_encode(input, errors='strict'):
    """Encode the input, returning a tuple (output object, length consumed).

    errors defines the error handling to apply. It defaults to
    'strict' handling which is the only currently supported
    error handling for this codec.

    """
    assert errors == 'strict'
    # using str() because of cStringIO's Unicode undesired Unicode behavior.
    f = StringIO(str(input))
    g = StringIO()
    quopri.encode(f, g, quotetabs=True)
    output = g.getvalue()
    return (output, len(input)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:quopri_codec.py

示例6: getregentry

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def getregentry():
    return codecs.CodecInfo(
        name='quopri',
        encode=quopri_encode,
        decode=quopri_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamwriter=StreamWriter,
        streamreader=StreamReader,
        _is_text_encoding=False,
    ) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:quopri_codec.py

示例7: quopri_encode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def quopri_encode(input, errors='strict'):
    assert errors == 'strict'
    f = BytesIO(input)
    g = BytesIO()
    quopri.encode(f, g, quotetabs=True)
    return (g.getvalue(), len(input)) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:8,代码来源:quopri_codec.py

示例8: encode

# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import encode [as 别名]
def encode(self, input, errors='strict'):
        return quopri_encode(input, errors) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:4,代码来源:quopri_codec.py


注:本文中的quopri.encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。