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