1 | n/a | """ Python 'oem' Codec for Windows |
---|
2 | n/a | |
---|
3 | n/a | """ |
---|
4 | n/a | # Import them explicitly to cause an ImportError |
---|
5 | n/a | # on non-Windows systems |
---|
6 | n/a | from codecs import oem_encode, oem_decode |
---|
7 | n/a | # for IncrementalDecoder, IncrementalEncoder, ... |
---|
8 | n/a | import codecs |
---|
9 | n/a | |
---|
10 | n/a | ### Codec APIs |
---|
11 | n/a | |
---|
12 | n/a | encode = oem_encode |
---|
13 | n/a | |
---|
14 | n/a | def decode(input, errors='strict'): |
---|
15 | n/a | return oem_decode(input, errors, True) |
---|
16 | n/a | |
---|
17 | n/a | class IncrementalEncoder(codecs.IncrementalEncoder): |
---|
18 | n/a | def encode(self, input, final=False): |
---|
19 | n/a | return oem_encode(input, self.errors)[0] |
---|
20 | n/a | |
---|
21 | n/a | class IncrementalDecoder(codecs.BufferedIncrementalDecoder): |
---|
22 | n/a | _buffer_decode = oem_decode |
---|
23 | n/a | |
---|
24 | n/a | class StreamWriter(codecs.StreamWriter): |
---|
25 | n/a | encode = oem_encode |
---|
26 | n/a | |
---|
27 | n/a | class StreamReader(codecs.StreamReader): |
---|
28 | n/a | decode = oem_decode |
---|
29 | n/a | |
---|
30 | n/a | ### encodings module API |
---|
31 | n/a | |
---|
32 | n/a | def getregentry(): |
---|
33 | n/a | return codecs.CodecInfo( |
---|
34 | n/a | name='oem', |
---|
35 | n/a | encode=encode, |
---|
36 | n/a | decode=decode, |
---|
37 | n/a | incrementalencoder=IncrementalEncoder, |
---|
38 | n/a | incrementaldecoder=IncrementalDecoder, |
---|
39 | n/a | streamreader=StreamReader, |
---|
40 | n/a | streamwriter=StreamWriter, |
---|
41 | n/a | ) |
---|