openmedialibrary_platform_d.../lib/python3.7/encodings/oem.py

42 lines
1,019 B
Python
Raw Permalink Normal View History

2018-12-31 23:25:26 +00:00
""" Python 'oem' Codec for Windows
2016-02-06 09:36:57 +00:00
"""
# Import them explicitly to cause an ImportError
# on non-Windows systems
2018-12-31 23:25:26 +00:00
from codecs import oem_encode, oem_decode
2016-02-06 09:36:57 +00:00
# for IncrementalDecoder, IncrementalEncoder, ...
import codecs
### Codec APIs
2018-12-31 23:25:26 +00:00
encode = oem_encode
2016-02-06 09:36:57 +00:00
def decode(input, errors='strict'):
2018-12-31 23:25:26 +00:00
return oem_decode(input, errors, True)
2016-02-06 09:36:57 +00:00
class IncrementalEncoder(codecs.IncrementalEncoder):
def encode(self, input, final=False):
2018-12-31 23:25:26 +00:00
return oem_encode(input, self.errors)[0]
2016-02-06 09:36:57 +00:00
class IncrementalDecoder(codecs.BufferedIncrementalDecoder):
2018-12-31 23:25:26 +00:00
_buffer_decode = oem_decode
2016-02-06 09:36:57 +00:00
class StreamWriter(codecs.StreamWriter):
2018-12-31 23:25:26 +00:00
encode = oem_encode
2016-02-06 09:36:57 +00:00
class StreamReader(codecs.StreamReader):
2018-12-31 23:25:26 +00:00
decode = oem_decode
2016-02-06 09:36:57 +00:00
### encodings module API
def getregentry():
return codecs.CodecInfo(
2018-12-31 23:25:26 +00:00
name='oem',
2016-02-06 09:36:57 +00:00
encode=encode,
decode=decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamreader=StreamReader,
streamwriter=StreamWriter,
)