将目录打包为文件,支持快速的文件访问和压缩
fast-package-file的Python项目详细描述
fast_package_文件
将目录打包到文件中,支持快速文件访问和压缩
importfast_package_file# Package a directory into a filefast_package_file.build('a_directory','a_package.file')# Prepare a package filedata_package=fast_package_file.PackagedDataFile('a_package.file')# Load a file from the packed directory and save itwithopen('any.file','wb')asany_file:data_package.load_file('path\\to\\any.file')# Or just get the raw binary datafromPILimportImagei=Image.open(io.BytesIO(data_package.load_file('image.png')))# Some other useful functionsdata_package.load_bulk(prefix='audio\\sfx\\',postfix='.wav')fast_package_file.oneshot('a_package.file','path\\to\\any.file')fast_package_file.oneshot_bulk('a_package.file',prefix='audio\\sfx\\',postfix='.wav')
安装
来自PYPI:
pip install fast-package-file
或来自github:
pip install git+git://github.com/Kataiser/fast-package-file.git@master#egg=fast_package_file
文档
更多详细信息请访问https://fast-package-file.readthedocs.io/en/latest/
功能
- 因为只从包文件加载所需的数据,所以速度很快,包的总大小与此无关
- 混淆(大多数)用户的文件
- 就像一个.zip文件,但在只读取一个文件时不会解压缩整个文件
- 包括整个目录和子目录,而不仅仅是表层文件
- 文件是用gzip压缩的,但前提是压缩改进了文件大小(每个文件)并启用了(每个包文件)
- 在加载包文件时,可以很好地处理错误,只需捕获fast_package_file.packagedataerror
- 灵感来自视频游戏包装,如ue4的.pak或gta v的.rpf格式
- 跨平台,具有Linux、MacOS和Windows的CI
贡献
- 问题跟踪器:https://github.com/Kataiser/fast-package-file/issues
- 源代码:https://github.com/Kataiser/fast-package-file
许可证
这个项目是根据麻省理工学院的许可证授权的。