Skip to main content

Python interface to libarchive

Project description

A Python interface to libarchive. It uses the standard ctypes module to dynamically load and access the C library.

Installation

pip install libarchive-c

python-libarchive-c is compatible with python 2 and 3.

Usage

Import:

import libarchive

To extract an archive to the current directory:

libarchive.extract_file('test.zip')

extract_memory extracts from a buffer instead, and extract_fd extracts from a file descriptor.

To read an archive:

with libarchive.file_reader('test.7z') as archive:
    for entry in archive:
        for block in entry.get_blocks():
            ...

memory_reader reads from a memory buffer instead, and fd_reader reads from a file descriptor.

To create an archive:

with libarchive.file_writer('test.tar.gz', 'ustar', 'gzip') as archive:
    archive.add_files('libarchive/', 'README.rst')

memory_writer writes to a memory buffer instead, fd_writer writes to a file descriptor, and custom_writer sends the data to a callback function.

You can also find more thorough examples in the tests/ directory.

License

LGPLv2 (or any later version)

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

libarchive-c-1.0.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

libarchive_c-1.0-py2.py3-none-any.whl (10.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file libarchive-c-1.0.tar.gz.

File metadata

  • Download URL: libarchive-c-1.0.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for libarchive-c-1.0.tar.gz
Algorithm Hash digest
SHA256 dc14871e6e38b908899835adeade6c95c9263c94e55309e0d9e5787ab52315b2
MD5 9766baa0dc60bb2a040877591271be1d
BLAKE2b-256 30563315f6f5a9761955c4109db24f407bb96a343f37e09e5ffcd9c0df45c461

See more details on using hashes here.

File details

Details for the file libarchive_c-1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for libarchive_c-1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ea29455e1df586bfe75fcbb446039064c17cb6b89d1fc790c797f6ac0a09531d
MD5 de304f88a9e10360f2c45cc9728d68a5
BLAKE2b-256 d7cad7a2afef3d5cb76f35ff8d963bee4d7a9862b43bf80799ca7f523c84427f

See more details on using hashes here.

Supported by

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