gufo.err.compressor¶
Compressor.
Compressor
¶
Bases: object
Compressor/decompressor class.
Use .encode() to compress data and .decode() to decompress.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
format |
Optional[str]
|
Compression algorithm. One of:
|
None
|
Raises:
Type | Description |
---|---|
ValueError
|
If format is not supported. |
autodetect(path)
classmethod
¶
Returns Compressor instance for given format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
File path |
required |
Returns:
Type | Description |
---|---|
Compressor
|
Compressor instance |
decode_bz2(data)
staticmethod
¶
Encoder for bz2
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
bzipped data as bytes. |
required |
Returns:
Type | Description |
---|---|
bytes
|
Ucompressed bytes. |
decode_gz(data)
staticmethod
¶
Decoder for gz
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
gzipped data as bytes. |
required |
Returns:
Type | Description |
---|---|
bytes
|
Ucompressed bytes. |
decode_none(data)
staticmethod
¶
Decoder for none
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
Input bytes |
required |
Returns:
Type | Description |
---|---|
bytes
|
data as is. |
decode_xz(data)
staticmethod
¶
Decoder for xz
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
xzipped data as bytes. |
required |
Returns:
Type | Description |
---|---|
bytes
|
Ucompressed bytes. |
encode_bz2(data)
staticmethod
¶
Encoder for bz2
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
Input bytes |
required |
Returns:
Type | Description |
---|---|
bytes
|
bzipped stream as bytes. |
encode_gz(data)
staticmethod
¶
Encoder for gz
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
Input bytes |
required |
Returns:
Type | Description |
---|---|
bytes
|
gzipped stream as bytes. |
encode_none(data)
staticmethod
¶
Encoder for none
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
Input bytes |
required |
Returns:
Type | Description |
---|---|
bytes
|
data as is. |
encode_xz(data)
staticmethod
¶
Encoder for xz
format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
bytes
|
Input bytes |
required |
Returns:
Type | Description |
---|---|
bytes
|
xzipped stream as bytes. |
get_format(path)
classmethod
¶
Auto-detect format from path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str
|
File path. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
|