def diff(src_bytes, dst_bytes): """diff(src_bytes, dst_bytes) -> bytes Return a BSDIFF4-format patch (from src_bytes to dst_bytes) as bytes. """ faux = StringIO() write_patch(faux, len(dst_bytes), *core.diff(src_bytes, dst_bytes)) return faux.getvalue()
def file_diff(src_path, dst_path, patch_path): """file_diff(src_path, dst_path, patch_path) Write a BSDIFF4-format patch (from the file src_path to the file dst_path) to the file patch_path. """ src = read_data(src_path) dst = read_data(dst_path) with open(patch_path, 'wb') as fo: write_patch(fo, len(dst), *core.diff(src, dst))
def file_diff(src_path, dst_path, patch_path): """file_diff(src_path, dst_path, patch_path) Write a BSDIFF4-format patch (from the file src_path to the file dst_path) to the file patch_path. """ src = read_data(src_path) dst = read_data(dst_path) fo = open(patch_path, 'wb') write_patch(fo, len(dst), *core.diff(src, dst)) fo.close()