MCPcopy Index your code
hub / github.com/reactive-python/reactpy / _PrintBuffer

Class _PrintBuffer

docs/docs_app/examples.py:143–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141
142
143class _PrintBuffer:
144 def __init__(self, max_lines: int = 10):
145 self._callback = None
146 self._lines = ()
147 self._max_lines = max_lines
148
149 def set_callback(self, function: Callable[[str], None]) -> None:
150 self._callback = function
151
152 def getvalue(self) -> str:
153 return "".join(self._lines)
154
155 def write(self, text: str) -> None:
156 if len(self._lines) == self._max_lines:
157 self._lines = self._lines[1:] + (text,)
158 else:
159 self._lines += (text,)
160 if self._callback is not None:
161 self._callback(self.getvalue())
162
163
164def _make_example_did_not_run(example_name):

Callers 1

_load_one_exampleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected