使用bsdiff4格式的二进制diff和补丁
bsdiff4的Python项目详细描述
代码主要来自于cx_bsdiff(由anthony tuininga编写, http://cx-bsdiff.sourceforge.net/)。进而导出cx_bsdiff代码 从bsdiff中,可以找到为bsd生成的独立实用程序 在http://www.daemonology.net/bsdiff。 除了cx_bsdiff提供的两个功能(diff和patch)之外,这个 套餐包括:
- an interface to the BSDIFF4-format
- command line interfaces: bsdiff4 and bspatch4
- tests
bsdiff4包定义了以下高级功能:
- diff(src_bytes, dst_bytes)->;字节
- 返回bsdiff4格式修补程序(从src_bytes到dst_bytes) 字节。
- patch(src_bytes, patch_bytes)->;字节
- 将bsdiff4格式patch_bytes应用到src_bytes,并返回 字节。
- file_diff(src_path, dst_path, patch_path)
- 将bsdiff4格式修补程序(从文件src_path写入 文件dst_path)到文件patch_path。
- file_patch(src_path, dst_path, patch_path)
- 将bsdiff4格式文件patch_path应用于文件src_path 并将结果写入文件dst_path。
- file_patch_inplace(path, patch_path)
- 将bsdiff4格式文件patch_path应用于文件path 到位。
示例:
>>> import bsdiff4 >>> a = bytes(100000 * 'a') >>> b = bytearray(a) >>> b[100:106] = ' diff ' >>> p = bsdiff4.diff(a, bytes(b)) >>> len(p) 154 >>> bsdiff4.patch(a, p) == b True