Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../encoding...
File: zlib_codec.py
"""Python 'zlib_codec' Codec - zlib compression encoding.
[0] Fix | Delete
[1] Fix | Delete
This codec de/encodes from bytes to bytes.
[2] Fix | Delete
[3] Fix | Delete
Written by Marc-Andre Lemburg (mal@lemburg.com).
[4] Fix | Delete
"""
[5] Fix | Delete
[6] Fix | Delete
import codecs
[7] Fix | Delete
import zlib # this codec needs the optional zlib module !
[8] Fix | Delete
[9] Fix | Delete
### Codec APIs
[10] Fix | Delete
[11] Fix | Delete
def zlib_encode(input, errors='strict'):
[12] Fix | Delete
assert errors == 'strict'
[13] Fix | Delete
return (zlib.compress(input), len(input))
[14] Fix | Delete
[15] Fix | Delete
def zlib_decode(input, errors='strict'):
[16] Fix | Delete
assert errors == 'strict'
[17] Fix | Delete
return (zlib.decompress(input), len(input))
[18] Fix | Delete
[19] Fix | Delete
class Codec(codecs.Codec):
[20] Fix | Delete
def encode(self, input, errors='strict'):
[21] Fix | Delete
return zlib_encode(input, errors)
[22] Fix | Delete
def decode(self, input, errors='strict'):
[23] Fix | Delete
return zlib_decode(input, errors)
[24] Fix | Delete
[25] Fix | Delete
class IncrementalEncoder(codecs.IncrementalEncoder):
[26] Fix | Delete
def __init__(self, errors='strict'):
[27] Fix | Delete
assert errors == 'strict'
[28] Fix | Delete
self.errors = errors
[29] Fix | Delete
self.compressobj = zlib.compressobj()
[30] Fix | Delete
[31] Fix | Delete
def encode(self, input, final=False):
[32] Fix | Delete
if final:
[33] Fix | Delete
c = self.compressobj.compress(input)
[34] Fix | Delete
return c + self.compressobj.flush()
[35] Fix | Delete
else:
[36] Fix | Delete
return self.compressobj.compress(input)
[37] Fix | Delete
[38] Fix | Delete
def reset(self):
[39] Fix | Delete
self.compressobj = zlib.compressobj()
[40] Fix | Delete
[41] Fix | Delete
class IncrementalDecoder(codecs.IncrementalDecoder):
[42] Fix | Delete
def __init__(self, errors='strict'):
[43] Fix | Delete
assert errors == 'strict'
[44] Fix | Delete
self.errors = errors
[45] Fix | Delete
self.decompressobj = zlib.decompressobj()
[46] Fix | Delete
[47] Fix | Delete
def decode(self, input, final=False):
[48] Fix | Delete
if final:
[49] Fix | Delete
c = self.decompressobj.decompress(input)
[50] Fix | Delete
return c + self.decompressobj.flush()
[51] Fix | Delete
else:
[52] Fix | Delete
return self.decompressobj.decompress(input)
[53] Fix | Delete
[54] Fix | Delete
def reset(self):
[55] Fix | Delete
self.decompressobj = zlib.decompressobj()
[56] Fix | Delete
[57] Fix | Delete
class StreamWriter(Codec, codecs.StreamWriter):
[58] Fix | Delete
charbuffertype = bytes
[59] Fix | Delete
[60] Fix | Delete
class StreamReader(Codec, codecs.StreamReader):
[61] Fix | Delete
charbuffertype = bytes
[62] Fix | Delete
[63] Fix | Delete
### encodings module API
[64] Fix | Delete
[65] Fix | Delete
def getregentry():
[66] Fix | Delete
return codecs.CodecInfo(
[67] Fix | Delete
name='zlib',
[68] Fix | Delete
encode=zlib_encode,
[69] Fix | Delete
decode=zlib_decode,
[70] Fix | Delete
incrementalencoder=IncrementalEncoder,
[71] Fix | Delete
incrementaldecoder=IncrementalDecoder,
[72] Fix | Delete
streamreader=StreamReader,
[73] Fix | Delete
streamwriter=StreamWriter,
[74] Fix | Delete
_is_text_encoding=False,
[75] Fix | Delete
)
[76] Fix | Delete
[77] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function