instruction module
Define a master class for Element and Command.
Todo
The line is edited to remove personalized name, weight and always have
the same arguments at the same position. But after I shall re-add them with
reinsert_optional_commands_in_line. This is very patchy and un-Pythonic.
- class Instruction(line, dat_idx=None, **kwargs)[source]
Bases:
ABCAn object corresponding to a line in a
DATfile.- n_attributes: int | range | Collection
- __init__(line, dat_idx=None, **kwargs)[source]
Instantiate corresponding line and line number in
DATfile.
- increment_dat_position(increment=1)[source]
Increment dat index for when another instruction is inserted.
- insert_dat_line(*args, dat_filecontent, previously_inserted=0, **kwargs)[source]
Insert the current object in the
dat_filecontentobject.- Parameters:
dat_filecontent (
list[DatLine]) – The list of instructions, in the form of a list of lines.previously_inserted (
int, default:0) – Number ofInstructionthat were already inserted in the givendat_filecontent.
- Return type:
- insert_line(*args, dat_filecontent, previously_inserted=0, **kwargs)[source]
Insert the current object in the
dat_filecontentobject.- Parameters:
dat_filecontent (
list[Collection[str]]) – The list of instructions, in the form of a list of lines.previously_inserted (
int, default:0) – Number ofInstructionthat were already inserted in the givendat_filecontent.
- Return type:
- insert_object(instructions)[source]
Insert current instruction in a list full of other instructions.
- Parameters:
instructions (
MutableSequence[Self])- Return type:
- classmethod from_args(dat_idx, *args, **kwargs)[source]
Instantiate instruction from its arguments directly.
- Parameters:
dat_idx (
int)- Return type:
Self
- classmethod _args_to_line(*args, **kwargs)[source]
Create the line of the dat file from arguments of the command.
- Return type:
- _abc_impl = <_abc._abc_data object at 0x7318faa95640>
- class Dummy(line, warning=False, **kwargs)[source]
Bases:
InstructionAn object corresponding to a non-implemented element or command.
- __init__(line, warning=False, **kwargs)[source]
Create the dummy object, raise a warning if necessary.
- _abc_impl = <_abc._abc_data object at 0x7318fb975700>