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

Method read

cmd2/utils.py:442–454  ·  view source on GitHub ↗

Read from the internal contents as a str and then clear them out. :param size: Number of bytes to read from the stream

(self, size: int | None = -1)

Source from the content-addressed store, hash-verified

440 return bytes(self.buffer.byte_buf)
441
442 def read(self, size: int | None = -1) -> str:
443 """Read from the internal contents as a str and then clear them out.
444
445 :param size: Number of bytes to read from the stream
446 """
447 if size is None or size == -1:
448 result = self.getvalue()
449 self.clear()
450 else:
451 result = self.buffer.byte_buf[:size].decode(encoding=self.encoding, errors=self.errors)
452 self.buffer.byte_buf = self.buffer.byte_buf[size:]
453
454 return result
455
456 def readbytes(self) -> bytes:
457 """Read from the internal contents as bytes and then clear them out."""

Callers 15

_reader_thread_funcMethod · 0.80
_restore_outputMethod · 0.80
_run_pythonMethod · 0.80
_initialize_historyMethod · 0.80
do_run_scriptMethod · 0.80
test_history_output_fileFunction · 0.80
test_run_scriptFunction · 0.80
test_relative_run_scriptFunction · 0.80
test_output_redirectionFunction · 0.80

Calls 2

getvalueMethod · 0.95
clearMethod · 0.95

Tested by 10

test_history_output_fileFunction · 0.64
test_run_scriptFunction · 0.64
test_relative_run_scriptFunction · 0.64
test_output_redirectionFunction · 0.64
test_stdsim_readFunction · 0.64