SequentialFileWriter¶
-
class
baseband.helpers.sequentialfile.
SequentialFileWriter
(files, mode=u'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: files : list, 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.mode : str, 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_size : int, 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).opener : callable, optional
Function to open a single file (default:
io.open
).Methods Summary
close
()Close the currently open local file, and therewith the set. memmap
([dtype, mode, offset, shape, order])Map part of the file in memory. tell
()Return the current stream position. write
(data)Write the given buffer to the IO stream. Methods Documentation
-
close
() [edit on github]¶ Close the currently open local file, and therewith the set.
-
memmap
(dtype=<type 'numpy.uint8'>, mode=None, offset=None, shape=None, order=u'C')[source] [edit on github]¶ Map part of the file in memory. Cannnot span file boundaries.
-
tell
() [edit on github]¶ Return the current stream position.
-
write
(data)[source] [edit on github]¶ Write the given buffer to the IO stream.
Returns the number of bytes written, which is always len(b).
Raises BlockingIOError if the buffer is full and the underlying raw stream cannot accept more data at the moment.
-