pooch.Decompress¶
-
class
pooch.
Decompress
(method='auto', name=None)[source]¶ Processor that decompress a file and returns the decompressed version.
Use with
pooch.Pooch.fetch
orpooch.retrieve
to decompress a downloaded data file so that it can be easily opened. Useful for data files that take a long time to decompress (exchanging disk space for speed).Supported decompression methods are LZMA (
.xz
), bzip2 (.bz2
), and gzip (.gz
).File names with the standard extensions (see above) can use
method="auto"
to automatically determine the compression method. This can be overwritten by setting the method argument.Note
To unpack zip and tar archives with one or more files, use
pooch.Unzip
andpooch.Untar
instead.The output file is
{fname}.decomp
by default but it can be changed by setting thename
parameter.Warning
Passing in
name
can cause existing data to be lost! For example, if a file already exists with the specified name it will be overwritten with the new decompressed file content. Use this option with caution.- Parameters
method (str) – Name of the compression method. Can be “auto”, “lzma”, “xz”, “bzip2”, or “gzip”.
name (None or str) – Defines the decompressed file name. The file name will be
{fname}.decomp
ifNone
(default) or the given name otherwise. Note that the name should not include the full (or relative) path, it should be just the file name itself.
Methods Summary
Decompress.__call__
(fname, action, pooch)Decompress the given file.
-
Decompress.
__call__
(fname, action, pooch)[source]¶ Decompress the given file.
The output file will be either
{fname}.decomp
or the given name class attribute.- Parameters
fname (str) – Full path of the compressed file in local storage.
action (str) –
Indicates what action was taken by
pooch.Pooch.fetch
orpooch.retrieve
:"download"
: File didn’t exist locally and was downloaded"update"
: Local file was outdated and was re-download"fetch"
: File exists and is updated so it wasn’t downloaded
pooch (
pooch.Pooch
) – The instance ofpooch.Pooch
that is calling this.
- Returns
fname (str) – The full path to the decompressed file.