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

Method save_text

rich/console.py:2224–2242  ·  view source on GitHub ↗

Generate text from console and save to a given location (requires record=True argument in constructor). Args: path (Union[str, PathLike[str]]): Path to write text files. clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``. st

(
        self,
        path: Union[str, PathLike[str]],
        *,
        clear: bool = True,
        styles: bool = False,
    )

Source from the content-addressed store, hash-verified

2222 return text
2223
2224 def save_text(
2225 self,
2226 path: Union[str, PathLike[str]],
2227 *,
2228 clear: bool = True,
2229 styles: bool = False,
2230 ) -> None:
2231 """Generate text from console and save to a given location (requires record=True argument in constructor).
2232
2233 Args:
2234 path (Union[str, PathLike[str]]): Path to write text files.
2235 clear (bool, optional): Clear record buffer after exporting. Defaults to ``True``.
2236 styles (bool, optional): If ``True``, ansi style codes will be included. ``False`` for plain text.
2237 Defaults to ``False``.
2238
2239 """
2240 text = self.export_text(clear=clear, styles=styles)
2241 with open(path, "w", encoding="utf-8") as write_file:
2242 write_file.write(text)
2243
2244 def export_html(
2245 self,

Callers 2

test_save_textFunction · 0.95
export.pyFile · 0.80

Calls 3

export_textMethod · 0.95
openFunction · 0.85
writeMethod · 0.45

Tested by 1

test_save_textFunction · 0.76