MCPcopy
hub / github.com/Textualize/rich / _ReadContext

Class _ReadContext

rich/progress.py:285–303  ·  view source on GitHub ↗

A utility class to handle a context for both a reader and a progress.

Source from the content-addressed store, hash-verified

283
284
285class _ReadContext(ContextManager[_I], Generic[_I]):
286 """A utility class to handle a context for both a reader and a progress."""
287
288 def __init__(self, progress: "Progress", reader: _I) -> None:
289 self.progress = progress
290 self.reader: _I = reader
291
292 def __enter__(self) -> _I:
293 self.progress.start()
294 return self.reader.__enter__()
295
296 def __exit__(
297 self,
298 exc_type: Optional[Type[BaseException]],
299 exc_val: Optional[BaseException],
300 exc_tb: Optional[TracebackType],
301 ) -> None:
302 self.progress.stop()
303 self.reader.__exit__(exc_type, exc_val, exc_tb)
304
305
306def wrap_file(

Callers 2

wrap_fileFunction · 0.85
openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected