Skip to main content

Simple library that provides a common interface for extracting zip and tar archives.

Project description

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.

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')

Note that calling extract with safe=True will ensure that the archive is safe prior to extraction: UnsafeArchive exception will be raised when archive contains paths which would be extracted outside of the target directory (e.g. absolute paths):

# Safely extract in directory 'unpack_dir'.
extract('files.tar.gz', 'unpack_dir', safe=True)

Similar tools

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Archive-0.2.tar.gz (8.9 kB view details)

Uploaded Source

File details

Details for the file Archive-0.2.tar.gz.

File metadata

  • Download URL: Archive-0.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for Archive-0.2.tar.gz
Algorithm Hash digest
SHA256 710e8d8c5c0af210445d80c754f355b2af53a4570f567c10b3c1c4f58836a7cf
MD5 5f185799a82c2c3b7f5bdd5096130ec5
BLAKE2b-256 a6476425ab7fdaa1741580eedb831bf52e6005a6e82738fe4be73d6d59bb7926

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page