Code to easily develop librsync bindings
This commit is contained in:
parent
0e9be57119
commit
f85f39e662
@ -136,3 +136,20 @@ class PatchFile(StreamingJob):
|
||||
|
||||
def __exit__(self, *a: object) -> None:
|
||||
self.close()
|
||||
|
||||
|
||||
def develop() -> None:
|
||||
import sys
|
||||
src = sys.argv[-1]
|
||||
sig_loader = LoadSignature()
|
||||
with open(src + '.sig', 'wb') as f:
|
||||
for chunk in signature_of_file(src):
|
||||
sig_loader(chunk)
|
||||
f.write(chunk)
|
||||
sig_loader()
|
||||
with open(src + '.delta', 'wb') as f, PatchFile(src, src + '.output') as patcher:
|
||||
for chunk in delta_for_file(src, sig_loader.signature):
|
||||
f.write(chunk)
|
||||
patcher.write(chunk)
|
||||
if not patcher.finished:
|
||||
patcher.write(b'')
|
||||
|
||||
@ -156,7 +156,7 @@ copy_callback(void *opaque, rs_long_t pos, size_t *len, void **buf) {
|
||||
if (!mem) { PyErr_Clear(); return RS_MEM_ERROR; }
|
||||
PyObject *res = PyObject_CallFunction(callback, "OL", mem, p);
|
||||
Py_DECREF(mem);
|
||||
if (res == NULL) { PyErr_Clear(); return RS_IO_ERROR; }
|
||||
if (res == NULL) { PyErr_Print(); return RS_IO_ERROR; }
|
||||
rs_result r = RS_DONE;
|
||||
if (PyLong_Check(res)) { *len = PyLong_AsSize_t(res); }
|
||||
else { r = RS_INTERNAL_ERROR; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user