util module

whoosh.util.fib(n)

Returns the nth value in the Fibonacci sequence.

whoosh.util.make_binary_tree(fn, args, **kwargs)

Takes a function/class that takes two positional arguments and a list of arguments and returns a binary tree of results/instances.

>>> make_binary_tree(UnionMatcher, [matcher1, matcher2, matcher3])
UnionMatcher(matcher1, UnionMatcher(matcher2, matcher3))

Any keyword arguments given to this function are passed to the class initializer.

whoosh.util.make_weighted_tree(fn, ls, **kwargs)

Takes a function/class that takes two positional arguments and a list of (weight, argument) tuples and returns a huffman-like weighted tree of results/instances.

whoosh.util.synchronized(func)

Decorator for storage-access methods, which synchronizes on a threading lock. The parent object must have ‘is_closed’ and ‘_sync_lock’ attributes.

whoosh.util.unclosed(method)

Decorator to check if the object is closed.