MCPcopy Index your code
hub / github.com/python/cpython / StdInputFile

Class StdInputFile

Lib/idlelib/run.py:481–525  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

479
480
481class StdInputFile(StdioFile):
482 _line_buffer = ''
483
484 def readable(self):
485 return True
486
487 def read(self, size=-1):
488 if self.closed:
489 raise ValueError("read from closed file")
490 if size is None:
491 size = -1
492 elif not isinstance(size, int):
493 raise TypeError('must be int, not ' + type(size).__name__)
494 result = self._line_buffer
495 self._line_buffer = ''
496 if size < 0:
497 while line := self.shell.readline():
498 result += line
499 else:
500 while len(result) < size:
501 line = self.shell.readline()
502 if not line: break
503 result += line
504 self._line_buffer = result[size:]
505 result = result[:size]
506 return result
507
508 def readline(self, size=-1):
509 if self.closed:
510 raise ValueError("read from closed file")
511 if size is None:
512 size = -1
513 elif not isinstance(size, int):
514 raise TypeError('must be int, not ' + type(size).__name__)
515 line = self._line_buffer or self.shell.readline()
516 if size < 0:
517 size = len(line)
518 eol = line.find('\n', 0, size)
519 if eol >= 0:
520 size = eol + 1
521 self._line_buffer = line[size:]
522 return line[:size]
523
524 def close(self):
525 self.shell.close()
526
527
528class MyHandler(rpc.RPCHandler):

Callers 2

__init__Method · 0.90
handleMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…