支持更多压缩格式的tarfile包装器。
xtarfile的Python项目详细描述
概述
包装tarfile以添加对更多压缩格式的支持。
用法
首先,使用希望支持的tarfile压缩格式安装库。 下面的示例显示了zstandard tarfile支持的安装。
pip install xtarfile[zstd]
现在,您可以像使用标准库tarfile模块一样使用xtarfile模块:
importxtarfileastarfilewithtarfile.open('some-archive','w:zstd')asarchive:archive.add('a-file.txt')withtarfile.open('some-archive','r:zstd')asarchive:archive.extractall()
另外,还支持基于文件扩展名检测正确的压缩模块:
importxtarfileastarfilewithtarfile.open('some-archive.tar.zstd','w')asarchive:archive.add('a-file.txt')withtarfile.open('some-archive.tar.zstd','r')asarchive:archive.extractall()
开发
使用pip install .[zstd]
安装项目的依赖项。
通过python3 setup.py test
运行测试。