ZIPCodec
digraph inheritance3483f34302 {
bgcolor=transparent;
rankdir=UD;
ratio=compress;
size="8.0, 12.0";
"Codec" [URL="taurus.core.util.codecs-Codec.html#taurus.core.util.codecs.Codec",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="The base class for all codecs"];
"Logger" -> "Codec" [arrowsize=0.5,style="setlinewidth(0.5)"];
"Logger" [URL="taurus-Logger.html#taurus.Logger",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="The taurus logger class. All taurus pertinent classes should inherit"];
"ZIPCodec" [URL="#taurus.core.util.codecs.ZIPCodec",color=dodgerblue1,fillcolor=white,fontcolor=black,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.5,shape=box,style=rounded,target="_top",tooltip="A codec able to encode/decode to/from gzip format. It uses the"];
"Codec" -> "ZIPCodec" [arrowsize=0.5,style="setlinewidth(0.5)"];
}
- class ZIPCodec[source]
A codec able to encode/decode to/from gzip format. It uses the
zlib
moduleExample:
>>> from taurus.core.util.codecs import CodecFactory >>> # first encode something >>> data = 100 * "Hello world\n" >>> cf = CodecFactory() >>> codec = cf.getCodec('zip') >>> format, encoded_data = codec.encode(("", data)) >>> print(len(data), len(encoded_data)) 1200, 31 >>> format, decoded_data = codec.decode((format, encoded_data)) >>> print(decoded_data[20]) 'Hello world\nHello wo'
Import from
taurus.core.util.codecs
as:from taurus.core.util.codecs import ZIPCodec
- decode(data, *args, **kwargs)[source]
decodes the given data from a gzip bytes.
- Parameters
data (sequence[str, obj]) – a sequence of two elements where the first item is the encoding format of the second item object
- Returns
a sequence of two elements where the first item is the encoding format of the second item object
- Return type
sequence[str, obj]
- encode(data, *args, **kwargs)[source]
encodes the given data to gzip bytes. The given data must be bytes
- Parameters
data (sequence[str, obj]) – a sequence of two elements where the first item is the encoding format of the second item object
- Returns
a sequence of two elements where the first item is the encoding format of the second item object
- Return type
sequence[str, obj]