ParsedHeaderBase

class baseband.base.header.ParsedHeaderBase(words, verify=True)[source] [edit on github]

Bases: object

Base class for all baseband headers using parsers.

Defines a number of common routines.

Generally, the actual class should define:

_header_parser : HeaderParser instance corresponding to this class.

_properties : tuple of properties accessible/usable in initialisation

It also should define properties that tell the size (getters and setters, or use a baseband.base.utils.fixedvalue if the value is the same for all instances):

payload_nbytes : number of bytes used by payload

frame_nbytes : total number of bytes for header + payload

get_time, set_time, and a corresponding time property :

time at start of payload

Parameters:
wordstuple or list

Header words. If given as a tuple, the header is immutable.

verifybool, optional

Whether to do basic verification of integrity.

Attributes Summary

mutable

Whether the header can be modified.

Methods Summary

copy(**kwargs)

Create a mutable and independent copy of the header.

fromkeys(*args, **kwargs)

Initialise a header from parsed values.

fromvalues(*args, **kwargs)

Initialise a header from parsed values.

keys()

All keys defined for this header.

update(*[, verify])

Update the header by setting keywords or properties.

verify()

Base verification always passes.

Attributes Documentation

mutable

Whether the header can be modified.

Methods Documentation

copy(**kwargs)[source] [edit on github]

Create a mutable and independent copy of the header.

Keyword arguments can be passed on as needed by possible subclasses.

classmethod fromkeys(*args, **kwargs)[source] [edit on github]

Initialise a header from parsed values.

Like fromvalues, but without any interpretation of keywords.

Raises:
KeyErrorif not all keys required are present in kwargs
classmethod fromvalues(*args, **kwargs)[source] [edit on github]

Initialise a header from parsed values.

Here, the parsed values must be given as keyword arguments, i.e., for any header = cls(<words>), cls.fromvalues(**header) == header.

However, unlike for the fromkeys class method, data can also be set using arguments named after header methods, such as time.

Parameters:
*args

Possible arguments required to initialize an empty header.

**kwargs

Values used to initialize header keys or methods.

keys()[source] [edit on github]

All keys defined for this header.

update(*, verify=True, **kwargs)[source] [edit on github]

Update the header by setting keywords or properties.

Here, any keywords matching header keys are applied first, and any remaining ones are used to set header properties, in the order set by the class (in _properties).

Parameters:
verifybool, optional

If True (default), verify integrity after updating.

**kwargs

Arguments used to set keywords and properties.

verify()[source] [edit on github]

Base verification always passes.

Only here for subclasses to be able to do super().