FileProxyMixin
A mixin class used to forward file methods to an underlying file object. The internal file object has to be called "file"::
class FileProxy(FileProxyMixin):
def __init__(self, file):
self.file = file
Attributes
| Attribute | Type | Description |
|---|---|---|
| encoding | string | The character encoding used to decode the underlying file's content. |
| fileno | integer | The integer file descriptor used by the underlying file object to request I/O operations from the operating system. |
| flush | callable | The method used to flush the write buffers of the underlying file object. |
| isatty | boolean | A boolean indicating whether the underlying file object is connected to a terminal device. |
| newlines | string or tuple | A string, tuple of strings, or None indicating the newline conventions encountered in the underlying file. |
| read | callable | The method used to read a specified number of bytes or characters from the underlying file. |
| readinto | callable | The method used to read bytes from the underlying file into a pre-allocated, writable bytes-like object. |
| readline | callable | The method used to read a single line from the underlying file. |
| readlines | callable | The method used to read all remaining lines from the underlying file and return them as a list. |
| seek | callable | The method used to change the stream position within the underlying file. |
| tell | callable | The method used to return the current stream position of the underlying file. |
| truncate | callable | The method used to resize the underlying file to a specified number of bytes. |
| write | callable | The method used to write a string or bytes to the underlying file. |
| writelines | callable | The method used to write a list of lines to the underlying file. |
| closed | boolean | A boolean indicating whether the underlying file object has been closed or is unavailable. |
Methods
closed()
@classmethod
def closed() - > boolean
Checks whether the underlying file object is closed or if the file reference is null.
Returns
| Type | Description |
|---|---|
boolean | True if the file is closed or missing, False otherwise |
readable()
@classmethod
def readable() - > boolean
Determines if the underlying file supports reading operations.
Returns
| Type | Description |
|---|---|
boolean | True if the file can be read from, False if it is closed or lacks read support |
writable()
@classmethod
def writable() - > boolean
Determines if the underlying file supports writing operations by checking the file's native method or its mode string.
Returns
| Type | Description |
|---|---|
boolean | True if the file is open and supports writing, False otherwise |
seekable()
@classmethod
def seekable() - > boolean
Determines if the underlying file supports random access via seek operations.
Returns
| Type | Description |
|---|---|
boolean | True if the file is open and supports seeking, False otherwise |