command module

Define the base class from which all commands will inherit.

class Command(line, dat_idx=None, **kwargs)[source]

Bases: Instruction

A generic Command class.

Parameters:
  • idx – Dictionary holding useful indexes. Keys are 'dat_idx' (position in the DAT file) and 'influenced_elements' (position in the DAT file of the elements concerned by current command).

  • line (DatLine) – Line in the DAT file corresponding to current command.

  • dat_idx (int | None)

Parameters:
__init__(line, dat_idx=None, **kwargs)[source]

Instantiate mandatory attributes.

Parameters:
Return type:

None

set_influenced_elements(instructions, **kwargs)[source]

Determine the index of the elements concerned by apply().

Parameters:
Return type:

None

abstractmethod apply(instructions, **kwargs)[source]

Apply the command.

Parameters:
Return type:

list[Instruction]

concerns_one_of(dat_indexes)[source]

Tell if self concerns an element, which dat_idx is given.

Internally, we convert the self.influenced from a set to a list object and check intersections with dat_indexes.

Parameters:

dat_indexes (Iterable[int]) – Indexes in the DAT file of the sub-list of elements under creation.

Return type:

bool

_indexes_between_this_command_and(instructions_after_self, *stop_types)[source]

Determine the indexes of the instructions affected by an instruction.

We return the indexes of instructions between the first of instructions and the first instruction which type is in stop_types.

Parameters:
  • instructions_after_self (Sequence[Instruction]) – All instructions after self (self not included).

  • stop_types (type) – Type(s) of commands after which self has no influence. If not provided, we set it to the type of self. In other words, a FREQ influences every element up to the following FREQ.

Return type:

slice

Returns:

All the indexes of the instrutions that will be affected by self.

increment_dat_position(increment=1)[source]

Increment dat_index and indexes of elements concerned by command.

Parameters:

increment (int, default: 1)

Return type:

None

_abc_impl = <_abc._abc_data object at 0x7318fb34c680>