Added "file-like" methods to DontReadFromInput

This commit is contained in:
Robert O'Shea 2022-07-28 02:13:51 +01:00
parent b4ab2f0942
commit 14bfe781f0
1 changed files with 26 additions and 0 deletions

View File

@ -203,12 +203,38 @@ class DontReadFromInput:
def fileno(self) -> int:
raise UnsupportedOperation("redirected stdin is pseudofile, has no fileno()")
def flush(self) -> None:
raise UnsupportedOperation("redirected stdin is pseudofile, has no flush()")
def isatty(self) -> bool:
return False
def close(self) -> None:
pass
def readable(self) -> bool:
return False
def seek(self, offset: int) -> int:
raise UnsupportedOperation("redirected stdin is pseudofile, has no seek(int)")
def seekable(self) -> bool:
return False
def tell(self) -> int:
raise UnsupportedOperation("redirected stdin is pseudofile, has no tell()")
def truncate(self, size: int) -> None:
raise UnsupportedOperation("cannont truncate stdin")
def write(self, byte) -> None:
raise UnsupportedOperation("cannot write to stdin")
writelines = write
def writable(self) -> bool:
return False
@property
def buffer(self):
return self