util module
- whoosh.util.make_binary_tree(fn: Callable[[T, T], T], args: Sequence[T], **kwargs: Any) T[source]
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: Callable[[Any, Any], Any], ls: list[tuple[Any, Any]], **kwargs: Any)[source]
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: Callable[[Concatenate[_SupportsSyncLock, P]], R]) Callable[[Concatenate[_SupportsSyncLock, P]], R][source]
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: Callable[[Concatenate[_SupportsClosed, P]], R]) Callable[[Concatenate[_SupportsClosed, P]], R][source]
Decorator to check if the object is closed.