pyppin.file.dev_null

[View Source]

An io.IOBase that behaves like /dev/null.

Classes

DevNull

RawDevNull

TextDevNull

class pyppin.file.dev_null.DevNull[source]

Bases: IOBase

close() None[source]

Flush and close the IO object.

This method has no effect if the file is already closed.

property closed: bool[source]
fileno() int[source]

Returns underlying file descriptor if one exists.

OSError is raised if the IO object does not use a file descriptor.

flush() None[source]

Flush write buffers, if applicable.

This is not implemented for read-only and non-blocking streams.

isatty() bool[source]

Return whether this is an ‘interactive’ stream.

Return False if it can’t be determined.

readable() bool[source]

Return whether object was opened for reading.

If False, read() will raise OSError.

seek(offset: int, whence: int = 0, /) int[source]

Change stream position.

Change the stream position to the given byte offset. The offset is interpreted relative to the position indicated by whence. Values for whence are:

  • 0 – start of stream (the default); offset should be zero or positive

  • 1 – current stream position; offset may be negative

  • 2 – end of stream; offset is usually negative

Return the new absolute position.

seekable() bool[source]

Return whether object supports random access.

If False, seek(), tell() and truncate() will raise OSError. This method may need to do a test seek().

tell() int[source]

Return current stream position.

truncate(size: Optional[int] = None, /) int[source]

Truncate file to size bytes.

File pointer is left unchanged. Size defaults to the current IO position as reported by tell(). Returns the new size.

writable() bool[source]

Return whether object was opened for writing.

If False, write() will raise OSError.

class pyppin.file.dev_null.RawDevNull[source]

Bases: DevNull, RawIOBase

read(size: int = -1, /) bytes[source]
readall() bytes[source]

Read until EOF, using multiple read() call.

readline(size: Optional[int] = -1, /) bytes[source]

Read and return a line from the stream.

If size is specified, at most size bytes will be read.

The line terminator is always b’n’ for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.

readlines(hint: int = -1, /) List[bytes][source]

Return a list of lines from the stream.

hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

readinto(b: Union[bytearray, array, memoryview, mmap, _CData, PickleBuffer], /) Optional[int][source]
write(b: Union[bytes, bytearray, array, memoryview, mmap, _CData, PickleBuffer], /) Optional[int][source]
writelines(lines: Iterable[Union[bytes, bytearray, array, memoryview, mmap, _CData, PickleBuffer]], /) None[source]

Write a list of lines to stream.

Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.

class pyppin.file.dev_null.TextDevNull[source]

Bases: DevNull, TextIOBase

property encoding: Optional[str][source]

Encoding of the text stream.

Subclasses should override.

property errors: Optional[str][source]

The error setting of the decoder or encoder.

Subclasses should override.

property newlines: Optional[Union[str, Tuple[str, ...]]][source]

Line endings translated so far.

Only line endings translated during reading are considered.

Subclasses should override.

detach() BinaryIO[source]

Separate the underlying buffer from the TextIOBase and return it.

After the underlying buffer has been detached, the TextIO is in an unusable state.

read(size: Optional[int] = -1, /) str[source]

Read at most n characters from stream.

Read from underlying buffer until we have n characters or we hit EOF. If n is negative or omitted, read until EOF.

readline(size: Optional[int] = -1, /) str[source]

Read and return a line from the stream.

If size is specified, at most size bytes will be read.

The line terminator is always b’n’ for binary files; for text files, the newlines argument to open can be used to select the line terminator(s) recognized.

readlines(hint: int = -1, /) List[str][source]

Return a list of lines from the stream.

hint can be specified to control the number of lines read: no more lines will be read if the total size (in bytes/characters) of all lines so far exceeds hint.

write(s: str, /) int[source]

Write string to stream. Returns the number of characters written (which is always equal to the length of the string).

writelines(lines: Iterable[str], /) None[source]

Write a list of lines to stream.

Line separators are not added, so it is usual for each of the lines provided to have a line separator at the end.