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).

Attributes Summary

file_nr

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.

Attributes Documentation

file_nr = None

Methods Documentation

close() [edit on github]

Close the currently open local file, and therewith the set.

memmap(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() [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 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.