kitty/kittens/transfer/librsync.py
2021-09-17 17:42:25 +05:30

22 lines
597 B
Python

#!/usr/bin/env python
# vim:fileencoding=utf-8
# License: GPLv3 Copyright: 2021, Kovid Goyal <kovid at kovidgoyal.net>
import os
from typing import Iterator
from .rsync import IO_BUFFER_SIZE, begin_signature, iter_job
def signature_of_file(path: str) -> Iterator[bytes]:
with open(path, 'rb') as f:
f.seek(0, os.SEEK_END)
fsz = f.tell()
job = begin_signature(fsz)
f.seek(0)
finished = False
while not finished:
input_data = f.read(IO_BUFFER_SIZE)
output, finished = iter_job(job, input_data)
yield output