duplicity.patchdir module

class duplicity.patchdir.IndexedTuple(index, sequence)[source]

Bases: object

Like a tuple, but has .index (used previously by collate_iters)

__init__(index, sequence)[source]
class duplicity.patchdir.Multivol_Filelike(tf, tar_iter, tarinfo_list, index)[source]

Bases: object

Emulate a file like object from multivols

Maintains a buffer about the size of a volume. When it is read() to the end, pull in more volumes as desired.

__init__(tf, tar_iter, tarinfo_list, index)[source]

Initializer. tf is TarFile obj, tarinfo is first tarinfo


Add next chunk to buffer


If not at end, read remaining data


Read length bytes from file

duplicity.patchdir.Patch(base_path, difftar_fileobj)[source]

Patch given base_path and file object containing delta

exception duplicity.patchdir.PatchDirException[source]

Bases: Exception

duplicity.patchdir.Patch_from_iter(base_path, fileobj_iter, restrict_index=())[source]

Patch given base_path and iterator of delta file objects

class duplicity.patchdir.PathPatcher(base_path)[source]

Bases: ITRBranch

Used by DirPatch, process the given basis and diff


Set base_path, Path of root of tree

can_fast_process(index, basis_path, diff_ropath)[source]

No need to recurse if diff_ropath isn’t a directory


Copy directory permissions when leaving tree

fast_process(index, basis_path, diff_ropath)[source]

For use when neither is a directory

start_process(index, basis_path, diff_ropath)[source]

Start processing when diff_ropath is a directory

class duplicity.patchdir.ROPath_IterWriter(base_path)[source]

Bases: ITRBranch

Used in Write_ROPaths above

We need to use an ITR because we have to update the permissions/times of directories after we write the files in them.


Set base_path, Path of root of tree

can_fast_process(index, ropath)[source]

Can fast process (no recursion) if ropath isn’t a directory


Update information of a directory when leaving it

fast_process(index, ropath)[source]

Write non-directory ropath to destination

start_process(index, ropath)[source]

Write ropath. Only handles the directory case

class duplicity.patchdir.TarFile_FromFileobjs(fileobj_iter)[source]

Bases: object

Like a tarfile.TarFile iterator, but read from multiple fileobjs


Make new tarinfo iterator

fileobj_iter should be an iterator of file objects opened for reading. They will be closed at end of reading.


Return data associated with given tarinfo


Set tarfile from next file object, or raise StopIteration

duplicity.patchdir.Write_ROPaths(base_path, rop_iter)[source]

Write out ropaths in rop_iter starting at base_path

Returns 1 if something was actually written, 0 otherwise.


Collate iterators by index

Input is a list of n iterators each of which must iterate elements with an index attribute. The elements must come out in increasing order, and the index should be a tuple itself.

The output is an iterator which yields tuples where all elements in the tuple have the same index, and the tuple has n elements in it. If any iterator lacks an element with that index, the tuple will have None in that spot.


Turn file-like difftarobj into iterator of ROPaths

duplicity.patchdir.filter_path_iter(path_iter, index)[source]

Rewrite path elements of path_iter so they start with index

Discard any that doesn’t start with index, and remove the index prefix from the rest.


Return (index, difftype, multivol) pair from tarinfo object


Combine a list of iterators of ropath patches

The iter_list should be sorted in patch order, and the elements in each iter_list need to be orderd by index. The output will be an iterator of the final ROPaths in index order.


Given an sequence of ROPath deltas, remove blank and unnecessary

The sequence is assumed to be in patch order (later patches apply to earlier ones). A patch is unnecessary if a later one doesn’t require it (for instance, any patches before a “delete” are unnecessary).

duplicity.patchdir.patch_diff_tarfile(base_path, diff_tarfile, restrict_index=())[source]

Patch given Path object using delta tarfile (as in tarfile.TarFile)

If restrict_index is set, ignore any deltas in diff_tarfile that don’t start with restrict_index.


Apply the patches in patch_seq, return single ropath

duplicity.patchdir.tarfiles2rop_iter(tarfile_list, restrict_index=())[source]

Integrate tarfiles of diffs into single ROPath iter

Then filter out all the diffs in that index which don’t start with the restrict_index.