spinn_storage_handlers package¶
Submodules¶
spinn_storage_handlers.exceptions module¶
-
exception
spinn_storage_handlers.exceptions.
DataReadException
¶ Bases:
exceptions.Exception
An exception that indicates that there was an error reading from the underlying medium
-
exception
spinn_storage_handlers.exceptions.
DataWriteException
¶ Bases:
exceptions.Exception
An exception that indicates that there was an error writing to the underlying medium
Module contents¶
-
class
spinn_storage_handlers.
FileDataReader
(filename)¶ Bases:
spinn_storage_handlers.abstract_classes.abstract_data_reader.AbstractDataReader
,spinn_storage_handlers.abstract_classes.abstract_context_manager.AbstractContextManager
A reader that can read data from a file.
Parameters: filename (str) – The file to read Raises: DataReadException – If the file cannot found or opened for reading -
close
()¶ Closes the file.
Return type: None Raises: DataReadException – If the file cannot be closed
-
read
(n_bytes=None)¶ Read some bytes of data from the underlying storage. Will block until some bytes are available, but might not return the full n_bytes. The size of the returned array indicates how many bytes were read.
Parameters: n_bytes (int) – The number of bytes to read; if unspecified, read all remaining bytes Returns: The data that was read Return type: bytearray Raises: IOError – If an error occurs reading from the underlying storage
-
readinto
(data)¶ Read some bytes of data from the underlying storage into a predefined array. Will block until some bytes are available, but may not fill the array completely.
Parameters: data (bytearray) – The place where the data is to be stored Returns: The number of bytes stored in data Return type: int Raises: IOError – If an error occurs reading from the underlying storage
-
tell
()¶ Returns the position of the file cursor.
Returns: Position of the file cursor Return type: int
-
-
class
spinn_storage_handlers.
FileDataWriter
(filename)¶ Bases:
spinn_storage_handlers.abstract_classes.abstract_data_writer.AbstractDataWriter
,spinn_storage_handlers.abstract_classes.abstract_context_manager.AbstractContextManager
Parameters: filename (str) – The file to write to Raises: DataWriteException – If the file cannot found or opened for writing -
close
()¶ Closes the file.
Return type: None Raises: DataWriteException – If the file cannot be closed
-
filename
¶ The name of the file that is being written to.
-
flush
()¶ Ensure that any buffers we have are written to disk.
-
tell
()¶ Returns the position of the file cursor.
Returns: Position of the file cursor Return type: int
-
write
(data)¶ Write some bytes of data to the underlying storage. Does not return until all the bytes have been written.
Parameters: data (bytearray or bytes) – The data to write Returns: Nothing is returned Return type: None Raises: IOError – If an error occurs writing to the underlying storage
-