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

Method write

rich/file_proxy.py:28–48  ·  view source on GitHub ↗
(self, text: str)

Source from the content-addressed store, hash-verified

26 return getattr(self.__file, name)
27
28 def write(self, text: str) -> int:
29 if not isinstance(text, str):
30 raise TypeError(f"write() argument must be str, not {type(text).__name__}")
31 buffer = self.__buffer
32 lines: List[str] = []
33 while text:
34 line, new_line, text = text.partition("\n")
35 if new_line:
36 lines.append("".join(buffer) + line)
37 buffer.clear()
38 else:
39 buffer.append(line)
40 break
41 if lines:
42 console = self.__console
43 with console:
44 output = Text("\n").join(
45 self.__ansi_decoder.decode_line(line) for line in lines
46 )
47 console.print(output)
48 return len(text)
49
50 def flush(self) -> None:
51 output = "".join(self.__buffer)

Callers 3

test_empty_bytesFunction · 0.95
test_flushFunction · 0.95
test_new_linesFunction · 0.95

Calls 6

TextClass · 0.85
joinMethod · 0.80
decode_lineMethod · 0.80
printMethod · 0.80
appendMethod · 0.45
clearMethod · 0.45

Tested by 3

test_empty_bytesFunction · 0.76
test_flushFunction · 0.76
test_new_linesFunction · 0.76