1# -*- coding: iso-8859-1 -*-
2""" Python 'escape' Codec
3
4
5Written by Martin v. L�wis (martin@v.loewis.de).
6
7"""
8import codecs
9
10class Codec(codecs.Codec):
11
12    encode = codecs.escape_encode
13    decode = codecs.escape_decode
14
15class IncrementalEncoder(codecs.IncrementalEncoder):
16    def encode(self, input, final=False):
17        return codecs.escape_encode(input, self.errors)[0]
18
19class IncrementalDecoder(codecs.IncrementalDecoder):
20    def decode(self, input, final=False):
21        return codecs.escape_decode(input, self.errors)[0]
22
23class StreamWriter(Codec,codecs.StreamWriter):
24    pass
25
26class StreamReader(Codec,codecs.StreamReader):
27    pass
28
29def getregentry():
30    return codecs.CodecInfo(
31        name='string-escape',
32        encode=Codec.encode,
33        decode=Codec.decode,
34        incrementalencoder=IncrementalEncoder,
35        incrementaldecoder=IncrementalDecoder,
36        streamwriter=StreamWriter,
37        streamreader=StreamReader,
38    )
39