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

Method capture

rich/console.py:1096–1111  ·  view source on GitHub ↗

A context manager to *capture* the result of print() or log() in a string, rather than writing it to the console. Example: >>> from rich.console import Console >>> console = Console() >>> with console.capture() as capture: ... cons

(self)

Source from the content-addressed store, hash-verified

1094 self.control(Control.bell())
1095
1096 def capture(self) -> Capture:
1097 """A context manager to *capture* the result of print() or log() in a string,
1098 rather than writing it to the console.
1099
1100 Example:
1101 >>> from rich.console import Console
1102 >>> console = Console()
1103 >>> with console.capture() as capture:
1104 ... console.print("[bold magenta]Hello World[/]")
1105 >>> print(capture.get())
1106
1107 Returns:
1108 Capture: Context manager with disables writing to the terminal.
1109 """
1110 capture = Capture(self)
1111 return capture
1112
1113 def pager(
1114 self, pager: Optional[Pager] = None, styles: bool = False, links: bool = False

Callers 15

test_vertical_align_topFunction · 0.95
test_renderFunction · 0.95
test_treeFunction · 0.95
test_refresh_screenFunction · 0.95
test_decode_exampleFunction · 0.95
test_wrap_cjk_mixedFunction · 0.95
test_append_tokensFunction · 0.95
test_soft_wrapFunction · 0.95
test_soft_wrap_styledFunction · 0.95
test_rich_prettyFunction · 0.95
test_rich_pretty_angularFunction · 0.95

Calls 1

CaptureClass · 0.85

Tested by 15

test_vertical_align_topFunction · 0.76
test_renderFunction · 0.76
test_treeFunction · 0.76
test_refresh_screenFunction · 0.76
test_decode_exampleFunction · 0.76
test_wrap_cjk_mixedFunction · 0.76
test_append_tokensFunction · 0.76
test_soft_wrapFunction · 0.76
test_soft_wrap_styledFunction · 0.76
test_rich_prettyFunction · 0.76
test_rich_pretty_angularFunction · 0.76