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

Python code coverage for Lib/encodings/charmap.py

#countcontent
1n/a""" Generic Python Character Mapping Codec.
2n/a
3n/a Use this codec directly rather than through the automatic
4n/a conversion mechanisms supplied by unicode() and .encode().
5n/a
6n/a
7n/aWritten by Marc-Andre Lemburg (mal@lemburg.com).
8n/a
9n/a(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
10n/a
11n/a"""#"
12n/a
13n/aimport codecs
14n/a
15n/a### Codec APIs
16n/a
17n/aclass Codec(codecs.Codec):
18n/a
19n/a # Note: Binding these as C functions will result in the class not
20n/a # converting them to methods. This is intended.
21n/a encode = codecs.charmap_encode
22n/a decode = codecs.charmap_decode
23n/a
24n/aclass IncrementalEncoder(codecs.IncrementalEncoder):
25n/a def __init__(self, errors='strict', mapping=None):
26n/a codecs.IncrementalEncoder.__init__(self, errors)
27n/a self.mapping = mapping
28n/a
29n/a def encode(self, input, final=False):
30n/a return codecs.charmap_encode(input, self.errors, self.mapping)[0]
31n/a
32n/aclass IncrementalDecoder(codecs.IncrementalDecoder):
33n/a def __init__(self, errors='strict', mapping=None):
34n/a codecs.IncrementalDecoder.__init__(self, errors)
35n/a self.mapping = mapping
36n/a
37n/a def decode(self, input, final=False):
38n/a return codecs.charmap_decode(input, self.errors, self.mapping)[0]
39n/a
40n/aclass StreamWriter(Codec,codecs.StreamWriter):
41n/a
42n/a def __init__(self,stream,errors='strict',mapping=None):
43n/a codecs.StreamWriter.__init__(self,stream,errors)
44n/a self.mapping = mapping
45n/a
46n/a def encode(self,input,errors='strict'):
47n/a return Codec.encode(input,errors,self.mapping)
48n/a
49n/aclass StreamReader(Codec,codecs.StreamReader):
50n/a
51n/a def __init__(self,stream,errors='strict',mapping=None):
52n/a codecs.StreamReader.__init__(self,stream,errors)
53n/a self.mapping = mapping
54n/a
55n/a def decode(self,input,errors='strict'):
56n/a return Codec.decode(input,errors,self.mapping)
57n/a
58n/a### encodings module API
59n/a
60n/adef getregentry():
61n/a return codecs.CodecInfo(
62n/a name='charmap',
63n/a encode=Codec.encode,
64n/a decode=Codec.decode,
65n/a incrementalencoder=IncrementalEncoder,
66n/a incrementaldecoder=IncrementalDecoder,
67n/a streamwriter=StreamWriter,
68n/a streamreader=StreamReader,
69n/a )