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

Python code coverage for Lib/encodings/base64_codec.py

#countcontent
1n/a"""Python 'base64_codec' Codec - base64 content transfer encoding.
2n/a
3n/aThis codec de/encodes from bytes to bytes.
4n/a
5n/aWritten by Marc-Andre Lemburg (mal@lemburg.com).
6n/a"""
7n/a
8n/aimport codecs
9n/aimport base64
10n/a
11n/a### Codec APIs
12n/a
13n/adef base64_encode(input, errors='strict'):
14n/a assert errors == 'strict'
15n/a return (base64.encodebytes(input), len(input))
16n/a
17n/adef base64_decode(input, errors='strict'):
18n/a assert errors == 'strict'
19n/a return (base64.decodebytes(input), len(input))
20n/a
21n/aclass Codec(codecs.Codec):
22n/a def encode(self, input, errors='strict'):
23n/a return base64_encode(input, errors)
24n/a def decode(self, input, errors='strict'):
25n/a return base64_decode(input, errors)
26n/a
27n/aclass IncrementalEncoder(codecs.IncrementalEncoder):
28n/a def encode(self, input, final=False):
29n/a assert self.errors == 'strict'
30n/a return base64.encodebytes(input)
31n/a
32n/aclass IncrementalDecoder(codecs.IncrementalDecoder):
33n/a def decode(self, input, final=False):
34n/a assert self.errors == 'strict'
35n/a return base64.decodebytes(input)
36n/a
37n/aclass StreamWriter(Codec, codecs.StreamWriter):
38n/a charbuffertype = bytes
39n/a
40n/aclass StreamReader(Codec, codecs.StreamReader):
41n/a charbuffertype = bytes
42n/a
43n/a### encodings module API
44n/a
45n/adef getregentry():
46n/a return codecs.CodecInfo(
47n/a name='base64',
48n/a encode=base64_encode,
49n/a decode=base64_decode,
50n/a incrementalencoder=IncrementalEncoder,
51n/a incrementaldecoder=IncrementalDecoder,
52n/a streamwriter=StreamWriter,
53n/a streamreader=StreamReader,
54n/a _is_text_encoding=False,
55n/a )