本文整理匯總了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)