本文整理汇总了Python中quopri.decode方法的典型用法代码示例。如果您正苦于以下问题:Python quopri.decode方法的具体用法?Python quopri.decode怎么用?Python quopri.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类quopri
的用法示例。
在下文中一共展示了quopri.decode方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: decode
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [as 别名]
def decode(input, output, encoding):
"""Decode common content-transfer-encodings (base64, quopri, uuencode)."""
if encoding == 'base64':
import base64
return base64.decode(input, output)
if encoding == 'quoted-printable':
import quopri
return quopri.decode(input, output)
if encoding in ('uuencode', 'x-uuencode', 'uue', 'x-uue'):
import uu
return uu.decode(input, output)
if encoding in ('7bit', '8bit'):
return output.write(input.read())
if encoding in decodetab:
pipethrough(input, decodetab[encoding], output)
else:
raise ValueError, \
'unknown Content-Transfer-Encoding: %s' % encoding
示例2: _decode
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [as 别名]
def _decode(self, headers, fileobj):
encoding = headers[-1].get_all("content-transfer-encoding", ["7bit"])[0]
encoding = encoding.lower()
if encoding == "base64":
try:
data = base64.b64decode(fileobj.read())
except TypeError as error:
self.log.error("Base64 decoding failed ({0})".format(error))
idiokit.stop(False)
return StringIO(data)
if encoding == "quoted-printable":
output = StringIO()
quopri.decode(fileobj, output)
output.seek(0)
return output
return fileobj
示例3: quopri_decode
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [as 别名]
def quopri_decode(input, errors='strict'):
"""Decode 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'
f = StringIO(str(input))
g = StringIO()
quopri.decode(f, g)
output = g.getvalue()
return (output, len(input))
示例4: decode
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [as 别名]
def decode(self, input,errors='strict'):
return quopri_decode(input,errors)
示例5: getregentry
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [as 别名]
def getregentry():
return codecs.CodecInfo(
name='quopri',
encode=quopri_encode,
decode=quopri_decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamwriter=StreamWriter,
streamreader=StreamReader,
)
示例6: getregentry
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [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,
)
示例7: quopri_decode
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [as 别名]
def quopri_decode(input, errors='strict'):
assert errors == 'strict'
f = BytesIO(input)
g = BytesIO()
quopri.decode(f, g)
return (g.getvalue(), len(input))
示例8: decode
# 需要导入模块: import quopri [as 别名]
# 或者: from quopri import decode [as 别名]
def decode(self, input, errors='strict'):
return quopri_decode(input, errors)