Overview¶
Path | PyPoE/poe/file/shared/__init__.py |
Version | 1.0.0a0 |
Revision | $Id: 3ce5c6fbd0c1571ff1128c461f032bd3fbdafa60 $ |
Author | Omega_K2 |
Description¶
Shared classes & functions for the file API. Used for exposing the same basic API.
All file classes inherit the base classes defined here or in the other shared file modules.
Warning
None of the abstract classes found here should be instantiated directly.
See also:
Agreement¶
See PyPoE/LICENSE
Todo
The abstract classes should probably actually be using python abc api.
Documentation¶
Abstract Classes¶
Bases:
PyPoE.shared.mixins.ReprMixin
Abstract Base Class for reading.
It provides common methods as well as methods that implementing classes should override.
Initialize self. See help(type(self)) for accurate signature.
Will attempt to open the given file_path_or_raw in read mode and pass the buffer to the specified function. The function must accept at least one keyword argument called ‘buffer’.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to read from
- args – Additional positional arguments to pass to the specified function
- kwargs – Additional keyword arguments to pass to the specified function
Returns: Result of the function
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
Reads the file contents into the specified path or buffer. This will also reset any existing contents of the file.
If a buffer or bytes was given, the data will be read from the buffer or bytes object.
If a file path was given, the resulting data will be read from the specified file.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to read from
- args – Additional positional arguments
- kwargs – Additional keyword arguments
Returns: result of the read operation, if any
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
Bases:
PyPoE.poe.file.shared.AbstractFileReadOnly
Abstract Base Class for reading and writing files.
It provides common methods as well as methods that implementing classes should override.
Initialize self. See help(type(self)) for accurate signature.
Will attempt to open the given file_path_or_raw in read mode and pass the buffer to the specified function. The function must accept at least one keyword argument called ‘buffer’.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to read from
- args – Additional positional arguments to pass to the specified function
- kwargs – Additional keyword arguments to pass to the specified function
Returns: Result of the function
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
Will attempt to open the given file_path_or_raw in write mode and pass the buffer to the specified function. The function must accept at least one keyword argument called ‘buffer’.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to write to
- args – Additional positional arguments to pass to the specified function
- kwargs – Additional keyword arguments to pass to the specified function
Returns: Result of the function
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
Reads the file contents into the specified path or buffer. This will also reset any existing contents of the file.
If a buffer or bytes was given, the data will be read from the buffer or bytes object.
If a file path was given, the resulting data will be read from the specified file.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to read from
- args – Additional positional arguments
- kwargs – Additional keyword arguments
Returns: result of the read operation, if any
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
Write the contents of file to the specified path or buffer.
If a buffer or bytes was given, a buffer object with the new data should be returned.
If a file path was given, the resulting data should be written to the specified file.
Parameters: - file_path_or_raw (BytesIO | bytes | str) – file path, bytes or buffer to write to
- args – Additional positional arguments
- kwargs – Additional keyword arguments
Returns: result of the write operation, if any
Return type: Raises: TypeError
– if file_path_or_raw has an invalid type
Exceptions & Warnings¶
Bases:
Exception
This exception or subclasses of this exception are raised when general errors related to the parsing of files occur, such as malformed files.
Initialize self. See help(type(self)) for accurate signature.
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
Bases:
UserWarning
This warning or subclasses of this warning are emitted when during the parsing process there are cases where issues are not severe enough to entirely fail the passing, but could pose serious problems.
Initialize self. See help(type(self)) for accurate signature.
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.