Bases: taurus.core.util.codecs.Codec
A codec able to encode/decode to/from gzip format. It uses the zlib module
Example:
>>> 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'
decodes the given data from a gzip string.
Parameters: | data (:class:~`sequence[str, obj]`) – a sequence of two elements where the first item is the encoding format of the second item object |
---|---|
Return type: | :class:~`sequence[str, obj]` |
Returns: | a sequence of two elements where the first item is the encoding format of the second item object |
encodes the given data to a gzip string. The given data must be a string
Parameters: | data (:class:~`sequence[str, obj]`) – a sequence of two elements where the first item is the encoding format of the second item object |
---|---|
Return type: | :class:~`sequence[str, obj]` |
Returns: | a sequence of two elements where the first item is the encoding format of the second item object |