ยปCore Development>Code coverage>Lib/encodings/quopri_codec.py

Python code coverage for Lib/encodings/quopri_codec.py

#countcontent
1n/a"""Codec for quoted-printable encoding.
2n/a
3n/aThis codec de/encodes from bytes to bytes.
4n/a"""
5n/a
6n/aimport codecs
7n/aimport quopri
8n/afrom io import BytesIO
9n/a
10n/adef quopri_encode(input, errors='strict'):
11n/a assert errors == 'strict'
12n/a f = BytesIO(input)
13n/a g = BytesIO()
14n/a quopri.encode(f, g, quotetabs=True)
15n/a return (g.getvalue(), len(input))
16n/a
17n/adef quopri_decode(input, errors='strict'):
18n/a assert errors == 'strict'
19n/a f = BytesIO(input)
20n/a g = BytesIO()
21n/a quopri.decode(f, g)
22n/a return (g.getvalue(), len(input))
23n/a
24n/aclass Codec(codecs.Codec):
25n/a def encode(self, input, errors='strict'):
26n/a return quopri_encode(input, errors)
27n/a def decode(self, input, errors='strict'):
28n/a return quopri_decode(input, errors)
29n/a
30n/aclass IncrementalEncoder(codecs.IncrementalEncoder):
31n/a def encode(self, input, final=False):
32n/a return quopri_encode(input, self.errors)[0]
33n/a
34n/aclass IncrementalDecoder(codecs.IncrementalDecoder):
35n/a def decode(self, input, final=False):
36n/a return quopri_decode(input, self.errors)[0]
37n/a
38n/aclass StreamWriter(Codec, codecs.StreamWriter):
39n/a charbuffertype = bytes
40n/a
41n/aclass StreamReader(Codec, codecs.StreamReader):
42n/a charbuffertype = bytes
43n/a
44n/a# encodings module API
45n/a
46n/adef getregentry():
47n/a return codecs.CodecInfo(
48n/a name='quopri',
49n/a encode=quopri_encode,
50n/a decode=quopri_decode,
51n/a incrementalencoder=IncrementalEncoder,
52n/a incrementaldecoder=IncrementalDecoder,
53n/a streamwriter=StreamWriter,
54n/a streamreader=StreamReader,
55n/a _is_text_encoding=False,
56n/a )