Skip to main content

filepack

A user-friendly interface for handling files, archives, and compressed files in Python.

Features

  • User-friendly interface for common file operations.
  • Support for various archive types: TAR, ZIP, RAR, SEVEN_ZIP.
  • Support for various compression types: GZIP, BZ2, LZ4, XZ.

Installation

pip install filepack

API Overview

FilePack

Method/Property Description
path Returns the path of the file.
suffix Returns the file's suffix.
is_compressed Check if the file is compressed.
uncompressed_size Get uncompressed size.
compressed_size Get compressed size.
compression_ratio Get compression ratio.
compress Compress the file.
decompress Decompress the file.

Archive

Method/Property Description
path Returns the path of the archive.
suffix Returns the archive's suffix.
extract_member Extract a specific member.
get_member Get member's metadata
get_members Get a list of members metadata.
add_member Add a member to the archive.
remove_member Remove a member from the archive.
extract_all Extract all members.
remove_all Remove all members from the archive.
print_members Print all members.

Compression

Method/Property Description
path Returns the path of the compressed file.
suffix Returns the file's suffix.
uncompressed_size Get uncompressed size.
compressed_size Get compressed size.
compression_ratio Get compression ratio.
compress Compress the file.
decompress Decompress the file.
is_compressed Check if the file is compressed.

Usage

Working with Archives

from filepack import FilePack


# if the given path can exist or not yet, but must refer to an archive.
file_pack = FilePack("path/to/your/archive/file")

# Extract a specific member
archive.extract_member(target_path="path/to/target/directory")

# Get a list of members
members = archive.get_members()

# Add a member to the archive
archive.add_member("path/to/member")

# Remove a member from the archive
archive.remove_member("name_of_member")

# Extract all members
archive.extract_all(target_path="path/to/target")

# Remove all members from the archive
archive.remove_all()

# Print all members
archive.print_members()

Working with Compressions

from filepack import FilePack


# if the given path must exist, but can refer to a file which is compressed already or not.
file_pack = FilePack("path/to/your/existed/file")

# Compressed or not
is_compressed = file_pack.is_compressed(compression_algorithm="gz")

# Get uncompressed size
size = file_pack.uncompressed_size(compression_algorithm="gz")

# Compress and decompress files in place
new_path = file_pack.compress(compression_algorithm="gz") # with .gz
new_path = file_pack.decompress(compression_algorithm="gz") # without .gz

# Compress and decompress files into a different path
new_path = file_pack.compress(target_path="path/to/compressed/file", compression_algorithm="gz")
new_path = file_pack.decompress(target_path="path/to/uncompressed/file", compression_algorithm="gz")

Working with Both

from filepack import FilePack


file_pack = FilePack("path/to/your/archive/file")

archive.add_member("path/to/member")
new_path = file_pack.compress(compression_algorithm="gz")

Error Handling

filepack has built-in error handling mechanisms. It raises user-friendly exceptions for common errors, allowing you to handle them gracefully in your application.

Contributing

Interested in contributing to filepack? See our contribution guide.

Metadata

Release files for filepack 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for filepack 0.1.0
File Size Uploaded Provenance
filepack-0.1.0.tar.gz 18.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for filepack 0.1.0
File Interpreter ABI Platform
filepack-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.8 kB

Release files / filepack-0.1.0.tar.gz

Download URL filepack-0.1.0.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
068a420a7fc9d4a96033fe6cc0a790640c8b1cfb6a8f34c24791c368e55bc450
BLAKE2b-256 checksum
How to use checksums
2eeff061e9345ca8c9c650c75530d1c750648464256b1fb50eb474d5aefc9e64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / filepack-0.1.0-py3-none-any.whl

Download URL filepack-0.1.0-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3238971612068cdd8ff621b859a01b5ec54e3568e5c8d3440b0cd9a653a4b2bd
BLAKE2b-256 checksum
How to use checksums
ee8c07146f4b4f19a756ba52ccbb109e543908438a43e187aa2b712b9d5048e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.5

Security for filepack 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page