jztools.contextlib#

Functions

environ(values[, clear])

Temporarily updates the enviornment variables using the specified values.

Classes

reentrant_context_manager(cm)

Class decorator or generator function decorator (a substitue for contextlib.contextmanager) that keeps track of number of entries to ensure a single one executes, returning that same object in every new context entry.

jztools.contextlib.environ(values: Dict[str, str], clear: bool = False) Generator[None, None, None]#

Temporarily updates the enviornment variables using the specified values. :param values: New environment variable values as a dictionary

class jztools.contextlib.reentrant_context_manager(cm: Type[AbstractContextManager] | Callable[[...], Generator])#

Bases: object

Class decorator or generator function decorator (a substitue for contextlib.contextmanager) that keeps track of number of entries to ensure a single one executes, returning that same object in every new context entry.

If the wrapped generator or class takes parameters, these are only used in the top-most entry and ignored in all nested entries.