Unified interface for tar, zip, sevenzip, and rar files
archivefile
is a wrapper around tarfile
, zipfile
, py7zr
, and rarfile
. It simplifies archive management tasks by providing a unified interface.
archivefile
is available on PyPI, so you can simply use pip to install it.
pip install archivefile
from archivefile import ArchiveFile
with ArchiveFile("archive.tar", "w") as archive:
archive.extract("member.txt") # Extract a single member of the archive
with ArchiveFile("archive.tar", "w") as archive:
archive.extractall(destination="~/output") # Extract all members
with ArchiveFile("archive.tar") as archive:
archive.read_text("member.txt") # Read a member of the archive