Unified interface for tar, zip, sevenzip, and rar files
Project description
Unified interface for tar, zip, sevenzip, and rar files
Table Of Contents
About
archivefile
is a wrapper around tarfile
, zipfile
, py7zr
, and rarfile
.
The above libraries are excellent when you are dealing with a single archive format but things quickly get annoying when you have a bunch of mixed archives such as .zip
, .7z
, .cbr
, .tar.gz
, etc because each library has a slightly different syntax and quirks which you need to deal with.
archivefile
wraps the common methods from the above libraries to provide a unified interface that takes care of said differences under the hood. However, it's not as powerful as the libraries it wraps due to lack of support for features that are unique to a specific archive format and library.
Installation
archivefile
is available on PyPI, so you can simply use pip to install it.
pip install archivefile
Usage
archivefile
offers a single class called ArchiveFile
to deal with various archive formats. Some examples are given below:
from archivefile import ArchiveFile
with ArchiveFile("archive.tar") as archive:
archive.extract("member.txt") # Extract a single member of the archive
with ArchiveFile("archive.zip", "w") as archive:
archive.extractall(destination="./archive/") # Extract all members
with ArchiveFile("archive.cb7") as archive:
archive.read_text("member.txt") # Read a member of the archive
with ArchiveFile("archive.rar") as archive:
archive.get_members() # Get a tuple of all the members of the archive
with ArchiveFile("archive.zip", "w") as archive:
archive.write("bar.txt") # write bar.txt to archive
Refer to the API reference for more details.
Docs
Checkout the complete documentation here.
License
Distributed under the Unlicense License. See UNLICENSE for more information.
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
Built Distribution
Hashes for archivefile-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 870a40fc41030a0177a0b3a72d67d7cad78475705872e687f37e7404e2a202be |
|
MD5 | 42b33bd6208a3c5279e689b0f7929fd6 |
|
BLAKE2b-256 | 9c9b053ce4ad7bf26576463fac96b3fb194fd6b7a6fb7f63848c55cf47e0471e |