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

Method _write_bytes

cmd2/utils.py:606–617  ·  view source on GitHub ↗

Write bytes to a stream. :param stream: the stream being written to :param to_write: the bytes being written.

(stream: StdSim | TextIO, to_write: bytes | str)

Source from the content-addressed store, hash-verified

604
605 @staticmethod
606 def _write_bytes(stream: StdSim | TextIO, to_write: bytes | str) -> None:
607 """Write bytes to a stream.
608
609 :param stream: the stream being written to
610 :param to_write: the bytes being written.
611 """
612 if isinstance(to_write, str):
613 to_write = to_write.encode()
614
615 # BrokenPipeError can occur if output is being piped to a process that closed
616 with contextlib.suppress(BrokenPipeError):
617 stream.buffer.write(to_write)
618
619
620class ContextFlag:

Callers 2

waitMethod · 0.95
_reader_thread_funcMethod · 0.95

Calls 1

writeMethod · 0.45

Tested by

no test coverage detected