<s> """<STR_LIT>""" <EOL> import codecs <EOL> import bz2 <EOL> def bz2_encode ( input , errors = '<STR_LIT:strict>' ) : <EOL> """<STR_LIT>""" <EOL> assert errors == '<STR_LIT:strict>' <EOL> output = bz2 . compress ( input ) <EOL> return ( output , len ( input ) ) <EOL> def bz2_decode ( input , errors = '<STR_LIT:strict>' ) : <EOL> """<STR_LIT>""" <EOL> assert errors == '<STR_LIT:strict>' <EOL> output = bz2 . decompress ( input ) <EOL> return ( output , len ( input ) ) <EOL> class Codec ( codecs . Codec ) : <EOL> def encode ( self , input , errors = '<STR_LIT:strict>' ) : <EOL> return bz2_encode ( input , errors ) <EOL> def decode ( self , input , errors = '<STR_LIT:strict>' ) : <EOL> return bz2_decode ( input , errors ) <EOL> class IncrementalEncoder ( codecs . IncrementalEncoder ) : <EOL> def __init__ ( self , errors = '<STR_LIT:strict>' ) : <EOL> assert errors == '<STR_LIT:strict>' <EOL> self . errors = errors <EOL> self . compressobj = bz2 . BZ2Compressor ( ) <EOL> def encode ( self , input , final = False ) : <EOL> if final : <EOL> c = self . compressobj . compress ( input ) <EOL> return c + self . compressobj . flush ( ) <EOL> else : <EOL> return self . compressobj . compress ( input ) <EOL> def reset ( self ) : <EOL> self . compressobj = bz2 . BZ2Compressor ( ) <EOL> class IncrementalDecoder ( codecs . IncrementalDecoder ) : <EOL> def __init__ ( self , errors = '<STR_LIT:strict>' ) : <EOL> assert errors == '<STR_LIT:strict>' <EOL> self . errors = errors <EOL> self . decompressobj = bz2 . BZ2Decompressor ( ) <EOL> def decode ( self , input , final = False ) : <EOL> try : <EOL> return self . decompressobj . decompress ( input ) <EOL> except EOFError : <EOL> return '<STR_LIT>' <EOL> def reset ( self ) : <EOL> self . decompressobj = bz2 . BZ2Decompressor ( ) <EOL> class StreamWriter ( Codec , codecs . StreamWriter ) : <EOL> pass <EOL> class StreamReader ( Codec , codecs . StreamReader ) : <EOL> pass <EOL> def getregentry ( ) : <EOL> return codecs . CodecInfo ( <EOL> name = "<STR_LIT>" , <EOL> encode = bz2_encode , <EOL> decode = bz2_decode , <EOL> incrementalencoder = IncrementalEncoder , <EOL> incrementaldecoder = IncrementalDecoder , <EOL> streamwriter = StreamWriter , <EOL> streamreader = StreamReader , <EOL> ) </s>
