info_item¶
- class baseband.base.file_info.info_item(attr=None, *, needs=(), default=None, doc=None, missing=None, copy=False)[source] [edit on github]¶
Bases:
object
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). Ifattr
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
. Ifattr
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 todefault
.- 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 themissing
attribute of the instance. Used, e.g., for Mark 5B to give a helpful message ifbps
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.
Methods Summary
__call__
(func)For use as a decorator when not yet fully initialized.
Methods Documentation
- __call__(func)[source] [edit on github]¶
For use as a decorator when not yet fully initialized.