jpayne@68: """ Python 'oem' Codec for Windows jpayne@68: jpayne@68: """ jpayne@68: # Import them explicitly to cause an ImportError jpayne@68: # on non-Windows systems jpayne@68: from codecs import oem_encode, oem_decode jpayne@68: # for IncrementalDecoder, IncrementalEncoder, ... jpayne@68: import codecs jpayne@68: jpayne@68: ### Codec APIs jpayne@68: jpayne@68: encode = oem_encode jpayne@68: jpayne@68: def decode(input, errors='strict'): jpayne@68: return oem_decode(input, errors, True) jpayne@68: jpayne@68: class IncrementalEncoder(codecs.IncrementalEncoder): jpayne@68: def encode(self, input, final=False): jpayne@68: return oem_encode(input, self.errors)[0] jpayne@68: jpayne@68: class IncrementalDecoder(codecs.BufferedIncrementalDecoder): jpayne@68: _buffer_decode = oem_decode jpayne@68: jpayne@68: class StreamWriter(codecs.StreamWriter): jpayne@68: encode = oem_encode jpayne@68: jpayne@68: class StreamReader(codecs.StreamReader): jpayne@68: decode = oem_decode jpayne@68: jpayne@68: ### encodings module API jpayne@68: jpayne@68: def getregentry(): jpayne@68: return codecs.CodecInfo( jpayne@68: name='oem', jpayne@68: encode=encode, jpayne@68: decode=decode, jpayne@68: incrementalencoder=IncrementalEncoder, jpayne@68: incrementaldecoder=IncrementalDecoder, jpayne@68: streamreader=StreamReader, jpayne@68: streamwriter=StreamWriter, jpayne@68: )