Giter Site home page Giter Site logo

pyrsync's Introduction

✨ pyrsync ✨

The python binding for librsync

pypi python implementation wheel license action

Install

pip install python-rsync

Usage

from io import BytesIO
from pyrsync import delta, get_signature_args, signature, patch

s = b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" * 50
d = b"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" * 50 + b"2"
src = BytesIO(s)
dst = BytesIO(d)
magic, block_len, strong_len = get_signature_args(len(s))
sig = BytesIO()
signature(dst, sig, strong_len, magic, block_len)  # sig由dst产生
dst.seek(0, 0)
sig.seek(0, 0)
_delta = BytesIO()
delta(src, sig, _delta)  # src和sig对比产生delta
src.seek(0, 0)
_delta.seek(0, 0)
out = BytesIO()
patch(dst, _delta, out)
assert out.getvalue() ==  src.getvalue()

Public functions

from typing import IO

class LibrsyncError(Exception):
    code: Any
    def __init__(self, result) -> None: ...

RS_JOB_BLOCKSIZE: int
RS_DELTA_MAGIC: int
RS_MD4_SIG_MAGIC: int
RS_BLAKE2_SIG_MAGIC: int
RS_RK_MD4_SIG_MAGIC: int
RS_RK_BLAKE2_SIG_MAGIC: int

def get_signature_args(old_fsize: int, magic: int = 0, block_len: int = 0, strong_len: int = 0) -> tuple: ...
def signature(input:IO, output:IO, strong_len: int, sig_magic: int, block_size: int = ...) -> None: ...
def delta(input:IO, sigfile:IO, output) -> None: ...
def patch(input:IO, delta:IO, output) -> None: ...

Compile

python -m pip install setuptools wheel cython cffi
git clone https://github.com/synodriver/pyrsync
cd pyrsync
git submodule update --init --recursive
python setup.py bdist_wheel --use-cython --use-cffi

Backend Choose

Use RSYNC_USE_CFFI env var to use cffi backend, otherwise it's depend on your python implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.