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

Compatibility

python-libarchive-c is currently tested with python 2.7, 3.3, 3.4, and 3.5.

If you find an incompatibility with older versions you can send us a small patch, but we won’t accept big changes.

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

CC0 Public Domain Dedication

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

Uploaded Source

Built Distribution

libarchive_c-2.7-py2.py3-none-any.whl (10.7 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

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

File hashes

Hashes for libarchive-c-2.7.tar.gz
Algorithm Hash digest
SHA256 56eadbc383c27ec9cf6aad3ead72265e70f80fa474b20944328db38bab762b04
MD5 6c23d0e2cc235a58bc5181f70f880375
BLAKE2b-256 1f4a7421e8db5c7509cf75e34b92a32b69c506f2b6f6392a909c2f87f3e94ad2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for libarchive_c-2.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1fac0e2dd5da1ba53d4c0641bfc7be2fed97dcb6c1cfcedb54db8807cdaf77d7
MD5 46629a244a0e03bee107b0c713e37a50
BLAKE2b-256 327a4b7ad7eed89528275cccc524135edd5c94c0dbefd524fd45ff22d4cd88c4

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