def write(self, data):
"""Takes any input data provided, decodes it as quoted-printable, and
passes it on to the underlying object.
:param data: quoted-printable data to decode
"""
# Prepend any cache info to our data.
if len(self.cache) > 0:
data = self.cache + data
# Since the longest possible escape is 3 characters long, either in
# the form '=XX' or '=\r\n', we encode up to 3 characters before the
# end of the string.
enc, rest = data[:-3], data[-3:]
# Encode and write, if we have data.
if len(enc) > 0:
self.underlying.write(binascii.a2b_qp(enc))
# Save remaining in cache.
self.cache = rest
return len(data)
评论列表
文章目录