本文整理匯總了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
示例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))
示例3: encode
# 需要導入模塊: import quopri [as 別名]
# 或者: from quopri import encode [as 別名]
def encode(self, input,errors='strict'):
return quopri_encode(input,errors)
示例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,
)
示例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))
示例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,
)
示例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))
示例8: encode
# 需要導入模塊: import quopri [as 別名]
# 或者: from quopri import encode [as 別名]
def encode(self, input, errors='strict'):
return quopri_encode(input, errors)