• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1""" Python 'latin-1' Codec
2
3
4Written by Marc-Andre Lemburg (mal@lemburg.com).
5
6(c) Copyright CNRI, All Rights Reserved. NO WARRANTY.
7
8"""
9import codecs
10
11### Codec APIs
12
13class Codec(codecs.Codec):
14
15    # Note: Binding these as C functions will result in the class not
16    # converting them to methods. This is intended.
17    encode = codecs.latin_1_encode
18    decode = codecs.latin_1_decode
19
20class IncrementalEncoder(codecs.IncrementalEncoder):
21    def encode(self, input, final=False):
22        return codecs.latin_1_encode(input,self.errors)[0]
23
24class IncrementalDecoder(codecs.IncrementalDecoder):
25    def decode(self, input, final=False):
26        return codecs.latin_1_decode(input,self.errors)[0]
27
28class StreamWriter(Codec,codecs.StreamWriter):
29    pass
30
31class StreamReader(Codec,codecs.StreamReader):
32    pass
33
34class StreamConverter(StreamWriter,StreamReader):
35
36    encode = codecs.latin_1_decode
37    decode = codecs.latin_1_encode
38
39### encodings module API
40
41def getregentry():
42    return codecs.CodecInfo(
43        name='iso8859-1',
44        encode=Codec.encode,
45        decode=Codec.decode,
46        incrementalencoder=IncrementalEncoder,
47        incrementaldecoder=IncrementalDecoder,
48        streamreader=StreamReader,
49        streamwriter=StreamWriter,
50    )
51