Skip to content

skimindex.unix.compress

skimindex.unix.compress

Compression tools wrapper module using plumbum.

Provides Pythonic interfaces to compression tools installed in the image
  • pigz: Parallel gzip compression
  • unzip: Extract ZIP archives
Two API styles
  1. Flexible: pigz("--help"), unzip("-l", "archive.zip")
  2. Convenient: pigz_compress("file.txt"), unzip_list("archive.zip")
Example

from skimindex.compress import pigz_compress, unzip_extract from plumbum import FG

Compress with parallel gzip

pigz_compress("file.txt") & FG

Extract ZIP archive

unzip_extract("-d", "/output", "archive.zip") & FG

Flexible API for custom pigz options

pigz("-p", "4", "-9", "file.txt") & FG

pigz

pigz(*args) -> LoggedBoundCommand

Execute a pigz command (parallel gzip compression).

Common options

-d: Decompress instead of compress -p N: Number of processes to use -9: Maximum compression -1: Fast compression -k: Keep input file

Examples:

pigz("file.txt") # compress pigz("-d", "file.txt.gz") # decompress pigz("-p", "4", "-9", "file.txt") # compress with 4 threads, max compression

Full documentation: pigz --help

pigz_compress

pigz_compress(*args) -> LoggedBoundCommand

Compress file(s) with parallel gzip.

pigz_decompress

pigz_decompress(*args) -> LoggedBoundCommand

Decompress file(s) with parallel gzip.

pigz_test

pigz_test(*args) -> LoggedBoundCommand

Test integrity of gzipped file(s).

unzip

unzip(*args) -> LoggedBoundCommand

Execute an unzip command.

Common subcommands/options: -l: List contents of archive -d DIR: Extract to directory -o: Overwrite without prompting -q: Quiet mode file: Extract specific file(s)

Examples:

unzip("-l", "archive.zip") # list contents unzip("-d", "/output", "archive.zip") # extract to directory unzip("archive.zip", "file.txt") # extract specific file unzip("-o", "archive.zip") # overwrite existing

Full documentation: unzip --help

unzip_list

unzip_list(*args) -> LoggedBoundCommand

List contents of archive.

unzip_extract

unzip_extract(*args) -> LoggedBoundCommand

Extract archive (unzip -d DIR archive.zip).

help

help(tool_name: str) -> str

Return the --help output for a compression tool.

Parameters:

Name Type Description Default
tool_name str

Executable name, e.g. "pigz" or "unzip".

required

Returns:

Type Description
str

Help text string, or an error message if the tool is not found.