CliCompressor#
- class composer.utils.CliCompressor(extension, cmd=None)[source]#
Base class for data compression CLI tools.
This class handles compression and decompression of data by piping it through CLI compressor tools installed on the system. e.g. the gzip command for producing .gz files.
Example: .. code-block:: python
compressor = CliCompressor(โgzโ, โgzipโ)
- with compressor.compress(โmyfile.txt.gzโ) as f:
f.write(โfooโ)
- with compressor.decompress(โmyfile.txt.gzโ) as f:
assert f.read() == โfooโ
- Parameters
- decompress(in_filename)[source]#
Decompress the content of the given file, providing the output as a file-like object.
- property exists#
Whether the CLI tool used by this compressor can be found.