使用lzw算法的任意文件的压缩程序和解压缩程序
lzw3的Python项目详细描述
使用LZW algorithm的压缩机和减压器 用Python写的。
要求
至少需要Python3.5。
安装
pip install lzw3
用法
两个脚本将安装在本地二进制路径中(例如 /home/user/.local/bin):compress和uncompress。如果你愿意 要调用这些脚本,请确保您的$PATH包含python 二进制路径注意,这个压缩程序只压缩常规文件(即 不创建.zip或.tar.gz等存档文件)。不管怎样,目录 仍然可以使用以下选项进行压缩:-r
压缩
压缩阶段用压缩的 一个,附加扩展名“.z”
压缩文件列表:
python3 -m lzw3.compressor doc1.txt doc2.txt
递归压缩目录:
python3 -m lzw3.compressor -r /home/user/Docs/Project
或者,您可以使用compress脚本,如下所示:
compress doc1.txt doc2.txt
选项
-r Recursively compress the files inside the directories within the given file list. If not specified, directories in the file list are skipped. -v Prints information about the handled files and the percentage of saved space for each compressed file. -t Prints the time spent for compress each file. -k Keeps the original files instead of replace those with the compressed ones. -f Force to compress and keep the compressed file, even if the size of the compressed file is higher than the size of the original one. -d Prints debug messages.
减压
解压阶段将替换压缩文件(扩展名为 “.z”)与未压缩的。
解压缩文件列表:
python3 -m lzw3.decompressor doc1.txt.Z doc2.txt.Z
递归解压缩目录:
python3 -m lzw3.decompressor -r /home/user/Docs/Project
或者,您可以使用uncompress脚本,如下所示:
uncompress doc1.txt.Z doc2.txt.Z
选项
-r Recursively decompress the files inside the directories within the given file list. If not specified, directories in the file list are skipped. -v Prints information about the handled files. -t Prints the time spent for decompress each file. -k Keeps the decompressed files after the decompression. -f Force to decompress the files even if the file name doesn't end with ".Z". -d Prints debug messages.
测试
这个项目带有很少的单元测试,无论是静态的还是随机的 生成的文件。要运行测试,请使用:
python3 setup.py test
许可证
lzw3是MIT licensed。