实现rsync二进制diff算法的python 3模块。
pyrsync2的Python项目详细描述
这是pyrsync包的一个分支,其中包含一些更改,如:
- The functions blockchecksums and rsyncdelta are now generators which make it easier to send through the network
- Some unittests are added
- Implementation changes (uses bytearray instead of a deque, faster hash lookup etc.)
- The block size is no longer in the delta itself, it needs to be passed to the patchstream function
- Does not use try/except for programming logic
这是一个python 3专用包!
pyrsync2是一个python模块,它实现了[rsync算法][1], 用纯python编写。它不是rsync的包装器,而是一组 通过python应用完整rsync功能的函数。
这个模块的大部分代码来自 在activestate[2]发布。它最初是根据[麻省理工学院许可证]授权的 [3],本许可证未作任何修改。
##安装
你需要有pip:
$ sudo pip install pyrsync2
##使用
此模块的示例用例:
# On the system containing the file that needs to be patched >>> import pyrsync2 >>> unpatched = open(“unpatched.file”, “rb”) >>> hashes = pyrsync2.blockchecksums(unpatched)
# On the remote system after having received hashes >>> import pyrsync2 >>> patchedfile = open(“patched.file”, “rb”) >>> delta = pyrsync2.rsyncdelta(patchedfile, hashes)
# System with the unpatched file after receiving delta >>> unpatched.seek(0) >>> save_to = open(“locally-patched.file”, “wb”) >>> pyrsync2.patchstream(unpatched, save_to, delta)
[1]:http://samba.anu.edu.au/rsync/“安德鲁·特里吉尔和保罗·麦凯拉斯。rsync算法。技术报告TR-CS-96-05,堪培拉0200法案,澳大利亚,1996年。” [2]:https://code.activestate.com/recipes/577518-rsync-algorithm/“rsync算法(python配方)” [3]:http://www.opensource.org/licenses/mit-license.php“OSI MIT许可证”