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.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 2Python 3

File details

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

File metadata

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

File hashes

Hashes for libarchive-c-1.1.tar.gz
Algorithm Hash digest
SHA256 276ebbf200613023eac6ac11c90eef95b3cca8edd8976d88f5785cafa7c2efbe
MD5 1e2811a63aa7007c6a2dbe7a5a0b3ace
BLAKE2b-256 9380ddba955aa3e1911ca961fc55d076a22b47841aaed807eb67cc9815d318d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libarchive_c-1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4a33c65f2cf93b759b7a236e9ad309ed84636f292409a285e94c71e1078b08da
MD5 c12ff8048b3baa804e091d558affe0e1
BLAKE2b-256 ed2719a2b32d406b77b0cdee3208c09fc902cbdfffce290dfb6beda5da1903ae

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