This package provides a simple, pure-Python interface for handling various archive file formats. Currently, archive extraction is the only supported action. Supported file formats include:
Zip formats and equivalents: .zip, .egg, .jar.
Tar and compressed tar formats: .tar, .tar.gz, .tgz, .tar.bz2, .tz2.
python-archive is compatible and tested with Python versions 2.5, 2.6, and 3.2.
Example usage
Using the Archive class:
from archive import Archive
a = Archive('files.tar.gz')
a.extract()
Using the extract convenience function:
from archive import extract
# Extract in current directory.
extract('files.tar.gz')
# Extract in directory 'unpack_dir'.
extract('files.tar.gz', 'unpack_dir')
By default, an archive.UnsafeArchive exception will be raised if any file(s) in the archive would be unpacked outside of the target directory (e.g. the archive contains absolute paths or relative paths that navigate up and out of the target directory). If you can trust the source of your archive files, then it’s possible to override this behavior, e.g.:
extract('files.tar.gz', method='insecure')
More examples
Passing a file-like object is also supported:
f = open('files.tar.gz', 'rb')
Archive(f).extract()
If a file does not have the correct extension, or is not recognized correctly, you may try explicitly specifying an extension (with leading period):
Archive('files.wrongext', ext='.tar.gz').extract()
# or
extract('files.wrongext', ext='.tar.gz')
Similar tools
http://pypi.python.org/pypi/patool/ - portable command line archive file manager.
http://pypi.python.org/pypi/gocept.download/ - zc.buildout recipe for downloading and extracting an archive.
Metadata
Release files for python-archive 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| python-archive-0.2.tar.gz | 9.2 kB | Without provenance | Details |
Release files / python-archive-0.2.tar.gz
| Download URL | python-archive-0.2.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f19c7bdd39a5f09ef86e56c5b2d5beb4a0635292639ee869a2b25bd9a2f1161
|
|
BLAKE2b-256 checksum How to use checksums |
4b17560776b5c88c0c665b54db9d076e7334b70fee5100a1bb52b18b92f9e123
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for python-archive 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.