Skip to main content

specfile.context_management

capture_stderr

@contextlib.contextmanager
def capture_stderr() -> Generator[List[bytes], None, None]

Context manager for capturing output to stderr. A stderr output of anything run in its context will be captured in the target variable of the with statement.

Yields:

List of captured lines.

GeneratorContextManager

class GeneratorContextManager(contextlib._GeneratorContextManager)

Extended contextlib._GeneratorContextManager that provides content property.

content

@property
def content() -> Any

Fully consumes the underlying generator and returns the yielded value.

Returns:

Value that would normally be the target variable of an associated with statement.

Raises:

  • StopIteration - If the underlying generator is already exhausted.

ContextManager

class ContextManager()

Class for decorating generator functions that should act as a context manager.

Just like with contextlib.contextmanager, the generator returned from the decorated function must yield exactly one value that will be used as the target variable of the with statement. If the same function with the same arguments is called again from within previously generated context, the generator will be ignored and the target variable will be reused.

Attributes:

  • function - Decorated generator function.
  • generators - Mapping of serialized function arguments to generators.
  • values - Mapping of serialized function arguments to yielded values.