jpayne@68: """ Python 'ascii' Codec jpayne@68: jpayne@68: jpayne@68: Written by Marc-Andre Lemburg (mal@lemburg.com). jpayne@68: jpayne@68: (c) Copyright CNRI, All Rights Reserved. NO WARRANTY. jpayne@68: jpayne@68: """ jpayne@68: import codecs jpayne@68: jpayne@68: ### Codec APIs jpayne@68: jpayne@68: class Codec(codecs.Codec): jpayne@68: jpayne@68: # Note: Binding these as C functions will result in the class not jpayne@68: # converting them to methods. This is intended. jpayne@68: encode = codecs.ascii_encode jpayne@68: decode = codecs.ascii_decode jpayne@68: jpayne@68: class IncrementalEncoder(codecs.IncrementalEncoder): jpayne@68: def encode(self, input, final=False): jpayne@68: return codecs.ascii_encode(input, self.errors)[0] jpayne@68: jpayne@68: class IncrementalDecoder(codecs.IncrementalDecoder): jpayne@68: def decode(self, input, final=False): jpayne@68: return codecs.ascii_decode(input, self.errors)[0] jpayne@68: jpayne@68: class StreamWriter(Codec,codecs.StreamWriter): jpayne@68: pass jpayne@68: jpayne@68: class StreamReader(Codec,codecs.StreamReader): jpayne@68: pass jpayne@68: jpayne@68: class StreamConverter(StreamWriter,StreamReader): jpayne@68: jpayne@68: encode = codecs.ascii_decode jpayne@68: decode = codecs.ascii_encode jpayne@68: jpayne@68: ### encodings module API jpayne@68: jpayne@68: def getregentry(): jpayne@68: return codecs.CodecInfo( jpayne@68: name='ascii', jpayne@68: encode=Codec.encode, jpayne@68: decode=Codec.decode, jpayne@68: incrementalencoder=IncrementalEncoder, jpayne@68: incrementaldecoder=IncrementalDecoder, jpayne@68: streamwriter=StreamWriter, jpayne@68: streamreader=StreamReader, jpayne@68: )