module documentation

Utilities for extracting common archive formats

Class UnrecognizedFormat Couldn't recognize the archive type
Function default_filter The default progress/filter callback; returns True for all files
Function unpack_archive Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``
Function unpack_directory "Unpack" a directory, using the same interface as for archives
Function unpack_tarfile Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
Function unpack_zipfile Unpack zip `filename` to `extract_dir`
Variable extraction_drivers Undocumented
Function _iter_open_tar Emit member-destination pairs from a tar archive.
Function _resolve_tar_file_or_dir Resolve any links and extract link targets as normal files.
Function _unpack_zipfile_obj Internal/private API used by other parts of setuptools. Similar to ``unpack_zipfile``, but receives an already opened :obj:`zipfile.ZipFile` object instead of a filename.
def default_filter(src, dst): (source)

The default progress/filter callback; returns True for all files

def unpack_archive(filename, extract_dir, progress_filter=default_filter, drivers=None): (source)

Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` `progress_filter` is a function taking two arguments: a source path internal to the archive ('/'-separated), and a filesystem path where it will be extracted. The callback must return the desired extract path (which may be the same as the one passed in), or else ``None`` to skip that file or directory. The callback can thus be used to report on the progress of the extraction, as well as to filter the items extracted or alter their extraction paths. `drivers`, if supplied, must be a non-empty sequence of functions with the same signature as this function (minus the `drivers` argument), that raise ``UnrecognizedFormat`` if they do not support extracting the designated archive type. The `drivers` are tried in sequence until one is found that does not raise an error, or until all are exhausted (in which case ``UnrecognizedFormat`` is raised). If you do not supply a sequence of drivers, the module's ``extraction_drivers`` constant will be used, which means that ``unpack_zipfile`` and ``unpack_tarfile`` will be tried, in that order.

def unpack_directory(filename, extract_dir, progress_filter=default_filter): (source)

"Unpack" a directory, using the same interface as for archives Raises ``UnrecognizedFormat`` if `filename` is not a directory

def unpack_tarfile(filename, extract_dir, progress_filter=default_filter): (source)

Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined by ``tarfile.open()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument.

def unpack_zipfile(filename, extract_dir, progress_filter=default_filter): (source)

Unpack zip `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument.

extraction_drivers = (source)

Undocumented

def _iter_open_tar(tar_obj, extract_dir, progress_filter): (source)

Emit member-destination pairs from a tar archive.

def _resolve_tar_file_or_dir(tar_obj, tar_member_obj): (source)

Resolve any links and extract link targets as normal files.

def _unpack_zipfile_obj(zipfile_obj, extract_dir, progress_filter=default_filter): (source)

Internal/private API used by other parts of setuptools. Similar to ``unpack_zipfile``, but receives an already opened :obj:`zipfile.ZipFile` object instead of a filename.