StreamReaderInfo

class baseband.base.file_info.StreamReaderInfo(parent=None)[source] [edit on github]

Bases: InfoBase

Standardized information on stream readers.

The info descriptor provides a few standard attributes, most of which can also be accessed directly on the stream filehandle, and tests basic readability of the stream. More detailed information on the underlying file is stored in its info, accessible via info.file_info (and shown by __repr__).

Attributes Summary

attr_names

Attributes that the container provides.

bps

Number of bits used to encode each elementary sample.

checks

dict of checks for readability.

closed

Whether parent is closed

complex_data

Whether the data are complex.

continuous

Check the stream is continuous.

errors

dict of attributes that raised errors

file_info

Information from the underlying file reader.

format

Format of the underlying file.

last_header

Like a lazy property, evaluated only once.

readable

Whether the stream can be read (possibly fixing errors).

sample_rate

Complete samples per unit of time.

shape

Equivalent shape of the whole file.

start_time

Time of the first complete sample.

stop_time

Time of the sample just beyond the end of the file.

verify

The type of verification done by the stream reader.

warnings

dict of attributes that gave warnings

Methods Summary

__call__()

Create a dict with information about the stream and the raw file.

Attributes Documentation

attr_names = ('start_time', 'stop_time', 'sample_rate', 'shape', 'format', 'bps', 'complex_data', 'verify', 'readable', 'checks', 'errors', 'warnings')

Attributes that the container provides.

bps

Number of bits used to encode each elementary sample.

checks

dict of checks for readability.

closed

Whether parent is closed

complex_data

Whether the data are complex.

continuous[source]

Check the stream is continuous.

Tries reading the very end. If there is a problem, will bisect to find the exact offset at which the problem occurs.

Errors are raised only to the extent verification is done. Hence, if the stream was opened with verify=False, many fewer problems will be found, while if it was opened with verify='fix', then for file types that support it, one will get warnings rather than exceptions (if the errors are fixable, of course).

errors

dict of attributes that raised errors

file_info[source]

Information from the underlying file reader.

format[source]

Format of the underlying file.

last_header[source]

Like a lazy property, evaluated only once.

Can be used as a decorator.

It replaces itself with the evaluation of the function, i.e., it is not a data descriptor.

Any errors encountered during the evaluation are stored in the instances errors dict.

Parameters:
attrstr or callable, optional

If a string, assumes we will get that attribute from needs. If a callable, it will be called with the instance as its argument to calculate the value (i.e., it will behave like a property). If attr is not given, its is set after the fact by applying the instance to a function (i.e., using it as a decorator), or by defining it as an attribute of a class.

needsstr or tuple of str

The attributes that need to be present to get or calculate attr. If attr is a string, this should be where the attribute should be gotten from (e.g., ‘header0’ or ‘_parent’); if not given, the attribute will simply be set to default.

defaultvalue, optional

The value to return if the needs are not met. Default: None.

docstr, optional

Docstring of the descriptor. If not given will be taken from attr if a function, otherwise constructed. (Hard to access from within python, but useful for sphinx documentation.)

missingstr, optional

If the value could be calculated or retrieved, but is None, then add this string to the missing attribute of the instance. Used, e.g., for Mark 5B to give a helpful message if bps is not found on the file reader instance.

copybool

Whether the copy the value if it is retrieved. This can be useful, e.g., if the value is expected to be a dict and an independent copy should be made.

readable[source]

Whether the stream can be read (possibly fixing errors).

sample_rate

Complete samples per unit of time.

shape

Equivalent shape of the whole file.

start_time

Time of the first complete sample.

stop_time[source]

Time of the sample just beyond the end of the file.

verify

The type of verification done by the stream reader.

warnings

dict of attributes that gave warnings

Methods Documentation

__call__()[source] [edit on github]

Create a dict with information about the stream and the raw file.