duplicity.lazy module

Define some lazy data structures and functions acting on them

class duplicity.lazy.ITRBranch[source]

Bases: object

Helper class for IterTreeReducer above

There are five stub functions below: start_process, end_process, branch_process, fast_process, and can_fast_process. A class that subclasses this one will probably fill in these functions to do more.

base_index = None
branch_process(branch)[source]

Process a branch right after it is finished (stub)

call_end_proc()[source]

Runs the end_process on self, checking for errors

can_fast_process(*args)[source]

True if object can be processed without new branch (stub)

caught_exception = None
end_process()[source]

Do any final processing before leaving branch (stub)

fast_process(*args)[source]

Process args without new child branch (stub)

finished = None
index = None
log_prev_error(index)[source]

Call function if no pending exception

on_error(exc, *args)[source]

This is run on any exception in start/end-process

start_process(*args)[source]

Do some initial processing (stub)

start_successful = None
class duplicity.lazy.Iter[source]

Bases: object

Hold static methods for the manipulation of lazy iterators

static And(iter)[source]

True if all elements in iterator are true. Short circuiting

static Or(iter)[source]

True if any element in iterator is true. Short circuiting

static cat(*iters)[source]

Lazily concatenate iterators

static cat2(iter_of_iters)[source]

Lazily concatenate iterators, iterated by big iterator

static empty(iter)[source]

True if iterator has length 0

static equal(iter1, iter2, verbose=None, operator=<function Iter.<lambda>>)[source]

True if iterator 1 has same elements as iterator 2

Use equality operator, or == if it is unspecified.

static filter(predicate, iterator)[source]

Like filter in a lazy functional programming language

static foldl(f, default, iter)[source]

the fundamental list iteration operator..

static foldr(f, default, iter)[source]

foldr the “fundamental list recursion operator”?

static foreach(function, iterator)[source]

Run function on each element in iterator

static len(iter)[source]

Return length of iterator

static map(function, iterator)[source]

Like map in a lazy functional programming language

static multiplex(iter, num_of_forks, final_func=None, closing_func=None)[source]

Split a single iterater into a number of streams

The return val will be a list with length num_of_forks, each of which will be an iterator like iter. final_func is the function that will be called on each element in iter just as it is being removed from the buffer. closing_func is called when all the streams are finished.

class duplicity.lazy.IterMultiplex2(iter)[source]

Bases: object

Multiplex an iterator into 2 parts

This is a special optimized case of the Iter.multiplex function, used when there is no closing_func or final_func, and we only want to split it into 2. By profiling, this is a time sensitive class.

__init__(iter)[source]
yielda()[source]

Return first iterator

yieldb()[source]

Return second iterator

class duplicity.lazy.IterTreeReducer(branch_class, branch_args)[source]

Bases: object

Tree style reducer object for iterator - stolen from rdiff-backup

The indicies of a RORPIter form a tree type structure. This class can be used on each element of an iter in sequence and the result will be as if the corresponding tree was reduced. This tries to bridge the gap between the tree nature of directories, and the iterator nature of the connection between hosts and the temporal order in which the files are processed.

This will usually be used by subclassing ITRBranch below and then call the initializer below with the new class.

Finish()[source]

Call at end of sequence to tie everything up

__init__(branch_class, branch_args)[source]

ITR initializer

add_branch()[source]

Return branch of type self.branch_class, add to branch list

finish_branches(index)[source]

Run Finish() on all branches index has passed

When we pass out of a branch, delete it and process it with the parent. The innermost branches will be the last in the list. Return None if we are out of the entire tree, and 1 otherwise.

process_w_branch(index, branch, args)[source]

Run start_process on latest branch