MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / write

Method write

cmd2/utils.py:421–432  ·  view source on GitHub ↗

Add str to internal bytes buffer and if echo is True, echo contents to inner stream. :param s: String to write to the stream

(self, s: str)

Source from the content-addressed store, hash-verified

419 self.buffer = ByteBuf(self)
420
421 def write(self, s: str) -> None:
422 """Add str to internal bytes buffer and if echo is True, echo contents to inner stream.
423
424 :param s: String to write to the stream
425 """
426 if not isinstance(s, str):
427 raise TypeError(f"write() argument must be str, not {type(s)}")
428
429 if not self.pause_storage:
430 self.buffer.byte_buf += s.encode(encoding=self.encoding, errors=self.errors)
431 if self.echo:
432 self.inner_stream.write(s)
433
434 def getvalue(self) -> str:
435 """Get the internal contents as a str."""

Callers 15

writeMethod · 0.45
_write_bytesMethod · 0.45
_redirect_outputMethod · 0.45
do_historyMethod · 0.45
_persist_historyMethod · 0.45
do_sayMethod · 0.45
do_tagMethod · 0.45
do_test_argparse_nsMethod · 0.45
do_arglistMethod · 0.45
do_preservelistMethod · 0.45
do_speakMethod · 0.45

Calls

no outgoing calls

Tested by 15

do_sayMethod · 0.36
do_tagMethod · 0.36
do_test_argparse_nsMethod · 0.36
do_arglistMethod · 0.36
do_preservelistMethod · 0.36
do_speakMethod · 0.36
help_cranberryMethod · 0.36
help_squatMethod · 0.36