Skip to main content

Python interface to libarchive

Project description

https://travis-ci.org/Changaco/python-libarchive-c.svg

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

Uploaded Source

Built Distribution

libarchive_c-2.1-py2.py3-none-any.whl (10.9 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for libarchive-c-2.1.tar.gz
Algorithm Hash digest
SHA256 56444ec811cd5eed653b058c04f839d47beca5d17197b14b99d665dfcdcf3421
MD5 34d3915a61a37f0d05516dbdfaef0db5
BLAKE2b-256 d1c61cc0ab7c1c4a561abaecbe781fc87d5d2dbd64d92da3b9442c8b1df5a999

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libarchive_c-2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 76fe773ec1f316da10a562d1568e0165ca03a10c0e805e2b58f7f68155a70e99
MD5 64d97f8bbce82c81b2eb765f3980b2fe
BLAKE2b-256 ef576383e854fa56f1310ba6a3ad3208a4402cb9eeadb80f5bf9c4fa38cb1981

See more details on using hashes here.

Supported by

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