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: DatLine, dat_idx: int | None = None, **kwargs)
Bases:
ABCAn object corresponding to a line in a
.datfile.- n_attributes: int | range | Collection
- __init__(line: DatLine, dat_idx: int | None = None, **kwargs) None
Instantiate corresponding line and line number in
.datfile.
- increment_dat_position(increment: int = 1) None
Increment dat index for when another instruction is inserted.
- insert_dat_line(*args, dat_filecontent: list[DatLine], previously_inserted: int = 0, **kwargs) None
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, optional) – Number of
Instructionthat were already inserted in the givendat_filecontent.
- insert_line(*args, dat_filecontent: list[Collection[str]], previously_inserted: int = 0, **kwargs) None
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, optional) – Number of
Instructionthat were already inserted in the givendat_filecontent.
- insert_object(instructions: MutableSequence[Self]) None
Insert current instruction in a list full of other instructions.
- classmethod from_args(dat_idx: int, *args, **kwargs) Self
Instantiate instruction from its arguments directly.
- classmethod _args_to_line(*args, **kwargs) str
Create the line of the dat file from arguments of the command.
- _abc_impl = <_abc._abc_data object at 0x7f370b42f840>
- class Dummy(line: DatLine, warning: bool = False, **kwargs)
Bases:
InstructionAn object corresponding to a non-implemented element or command.
- __init__(line: DatLine, warning: bool = False, **kwargs) None
Create the dummy object, raise a warning if necessary.
- _abc_impl = <_abc._abc_data object at 0x7f36fbb3fec0>