PageRenderTime 212ms CodeModel.GetById 121ms app.highlight 3ms RepoModel.GetById 87ms app.codeStats 0ms

/Lib/encodings/string_escape.py

http://unladen-swallow.googlecode.com/
Python | 38 lines | 37 code | 0 blank | 1 comment | 0 complexity | b8281e005eec55dffbf16ae8baeeaa72 MD5 | raw file
 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    )