SequentialFileWriter¶
-
class
baseband.helpers.sequentialfile.
SequentialFileWriter
(files, mode='w+b', file_size=None, opener=None)[source] [edit on github]¶ Bases:
baseband.helpers.sequentialfile.SequentialFileBase
Write several files as if they were one contiguous one.
Note that the file is not seekable and readable.
- Parameters
- fileslist, tuple, or other iterable of str, filehandle
The contains the names of the underlying files that should be combined. If not a list or tuple, it should allow indexing with positive indices (e.g., returning a name as derived from a template). It should raise raise
IndexError
if the index is out of range.- modestr, optional
The mode with which the files should be opened (default: ‘w+b’). If this does not include ‘+’ for reading, memory maps are not possibe.
- file_sizeint, optional
The maximum size a file is allowed to have. Default:
None
, which means it is unlimited and only a single file will be written (making using this class somewhat pointless).- openercallable, optional
Function to open a single file (default:
io.open
).
Methods Summary
close
(self)Close the currently open local file, and therewith the set.
memmap
(self[, dtype, mode, offset, shape, order])Map part of the file in memory.
tell
(self)Return the current stream position.
write
(self, data)Write the given buffer to the IO stream.
Methods Documentation
-
close
(self) [edit on github]¶ Close the currently open local file, and therewith the set.
-
memmap
(self, dtype=<class 'numpy.uint8'>, mode=None, offset=None, shape=None, order='C')[source] [edit on github]¶ Map part of the file in memory. Cannnot span file boundaries.
-
tell
(self) [edit on github]¶ Return the current stream position.
-
write
(self, data)[source] [edit on github]¶ Write the given buffer to the IO stream.
Returns the number of bytes written, which is always the length of b in bytes.
Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment.