A native asynchronous library for file decompression and archiving in Python.
Project description
aiozip
aiozip 是一个使用原生 asyncio 构建的 Python 库,用于高性能地异步处理归档文件。
当前阶段专注于提供一个简单、统一的 API 来解压各种常见的归档格式。
✨ 主要特性
- 原生异步: 对
.zip文件实现了从零开始的原生异步解压,无任何阻塞I/O。 - 统一 API: 一个简单的
aiozip.uncompress()函数即可处理多种格式。 - 多格式支持: 目前支持
.zip,.tar,.tar.gz,.tar.bz2。 - 轻量级: 仅依赖
aiofiles,保持最小的依赖。 - 现代 & 类型提示: 使用现代 Python 特性 (Python 3.8+) 并提供完整的类型提示。
🚀 安装
pip install aiozip
💡 快速开始
使用 aiozip 非常简单。下面是一个解压 .zip 和 .tar.gz 文件的例子:
import asyncio
import aiozip
async def main():
try:
print("正在解压 zip 文件...")
# 假设你有一个 my_archive.zip 文件
await aiozip.uncompress("my_archive.zip", "./unzipped_files")
print("解压完成!")
except aiozip.AiozipError as e:
print(f"发生了一个错误: {e}")
if __name__ == "__main__":
asyncio.run(main())
API
await aiozip.uncompress(source_path, dest_path)
异步解压一个归档文件。
source_path(str): 源归档文件的路径。dest_path(str): 解压目标目录的路径。
异常
aiozip.ArchiveNotFoundError: 源文件未找到。aiozip.UnsupportedFormatError: 不支持的归档格式。aiozip.CorruptArchiveError: 归档文件已损坏。
未来计划
- 实现原生异步的文件压缩功能。
- 支持更多归档格式 (如 .7z, .rar)。
- 支持对加密归档文件的处理。
🤝 贡献
欢迎任何形式的贡献!请随时提交 Pull Request 或创建 Issue。
📄 许可证
本项目使用 MIT 许可证。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiozip-0.1.0.tar.gz
(8.7 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiozip-0.1.0.tar.gz.
File metadata
- Download URL: aiozip-0.1.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27a3637c052934748cfbe79642f05df041777ccccad44f5285d4deb1e2174f0f
|
|
| MD5 |
00fe5a5f942b0830d40c0b3f827e56b7
|
|
| BLAKE2b-256 |
22251dbc16683d07a94a0a5a7de7463586752bf615fd66b49efc6c53d12164fe
|
File details
Details for the file aiozip-0.1.0-py3-none-any.whl.
File metadata
- Download URL: aiozip-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
866771b0af691472723648364cfa3239ad1d0125da996f9b5599d181f849765c
|
|
| MD5 |
20b26c4872e13a7eb8022505bca5bcfe
|
|
| BLAKE2b-256 |
90dab1ef071006897ac05af387f692767951f83a77df5674d7ca0e51f55c36af
|