4.5.1. Sequence#

class caterpillar.model.Sequence(model, order=None, arch=None, options=None, field_options=None)[source]#

Default implementation for a sequence of fields.

The native Python type mapped to this struct class is dict. To convert a dictionary into a sequence, you can either use the contructor directly or apply the type converter for this class:

>>> to_struct({'a': uint8})
Sequence(fields=['a'])

Changed in version 2.6.0: The Sequence class now internally uses another class (_Member) to store the fields and actions.

has_option(option: Flag) bool[source]#

Check if the struct has a specific option.

Parameters:

option – The option to check.

Returns:

True if the struct has the specified option, else False.

add_field(name: str, field: Field, included: bool = False) None[source]#

Add a field to the struct.

Parameters:
  • name – The name of the field.

  • field – The field to add.

  • included – True if the field should be included, else False.

add_action(action) None[source]#

Add an action to the struct.

Parameters:

action – The action to add.

del_field(name: str, field) None[source]#

Remomves a field from this struct.

Parameters:
  • name – The name of the field.

  • field – The field to remove.