我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用quopri.decode()。
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
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
def quopri_decode(input, errors='strict'): assert errors == 'strict' f = BytesIO(input) g = BytesIO() quopri.decode(f, g) return (g.getvalue(), len(input))
def decode(self, input, errors='strict'): return quopri_decode(input, errors)
def decode(self, input, final=False): return quopri_decode(input, self.errors)[0]
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, )
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))
def decode(self, input,errors='strict'): return quopri_decode(input,errors)
def getregentry(): return codecs.CodecInfo( name='quopri', encode=quopri_encode, decode=quopri_decode, incrementalencoder=IncrementalEncoder, incrementaldecoder=IncrementalDecoder, streamwriter=StreamWriter, streamreader=StreamReader, )