duplicity.librsync module

Provides a high-level interface to some librsync functions

This is a python wrapper around the lower-level _librsync module, which is written in C. The goal was to use C as little as possible…

class duplicity.librsync.DeltaFile(signature, new_file)[source]

Bases: LikeFile

File-like object which incrementally generates a librsync delta

__init__(signature, new_file)[source]

DeltaFile initializer - call with signature and new file

Signature can either be a string or a file with read() and close() methods. New_file also only needs to have read() and close() methods. It will be closed when self is closed.

class duplicity.librsync.LikeFile(infile, need_seek=None)[source]

Bases: object

File-like object used by SigFile, DeltaFile, and PatchFile

__init__(infile, need_seek=None)[source]

LikeFile initializer - zero buffers, set eofs off


Make sure len(self.inbuf) >= blocksize


Add one cycle’s worth of output to self.outbuf

check_file(file, need_seek=None)[source]

Raise type error if file doesn’t have necessary attributes


Close infile

maker = None
mode = 'rb'

Build up self.outbuf, return first length bytes

class duplicity.librsync.PatchedFile(basis_file, delta_file)[source]

Bases: LikeFile

File-like object which applies a librsync delta incrementally

__init__(basis_file, delta_file)[source]

PatchedFile initializer - call with basis delta

Here basis_file must be a true Python file, because we may need to seek() around in it a lot, and this is done in C. delta_file only needs read() and close() methods.

class duplicity.librsync.SigFile(infile, blocksize=duplicity._librsync.RS_DEFAULT_BLOCK_LEN)[source]

Bases: LikeFile

File-like object which incrementally generates a librsync signature

__init__(infile, blocksize=duplicity._librsync.RS_DEFAULT_BLOCK_LEN)[source]

SigFile initializer - takes basis file

basis file only needs to have read() and close() methods. It will be closed when we come to the end of the signature.

class duplicity.librsync.SigGenerator(blocksize=duplicity._librsync.RS_DEFAULT_BLOCK_LEN)[source]

Bases: object

Calculate signature.

Input and output is same as SigFile, but the interface is like md5 module, not filelike object


Return new signature instance


Return signature over given data


Run self.buffer through sig_maker, add to self.sig_string


Add buf to data that signature will be calculated over

exception duplicity.librsync.librsyncError[source]

Bases: Exception

Signifies error in internal librsync processing (bad signature, etc.)

underlying _librsync.librsyncError’s are regenerated using this class because the C-created exceptions are by default unPickleable. There is probably a way to fix this in _librsync, but this scheme was easier.