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: list[str], dat_idx: int, name: str | None = None, **kwargs)
Bases:
ABCAn object corresponding to a line in a
.datfile.- n_attributes: int | range | Collection
- __init__(line: list[str], dat_idx: int, name: str | None = None, **kwargs) None
Instantiate corresponding line and line number in
.datfile.
- to_line(*args, inplace: bool = False, with_name: bool = False, **kwargs) list[str]
Convert the object back into a
.datline.- Parameters:
- Returns:
A line of the
.datfile. The arguments are each an element in the list.- Return type:
- Raises:
NotImplementedError –
with_name = True & inplace = Truecurrently raises an error as I do not want the name of the element to be inserted several times.
- increment_dat_position(increment: int = 1) None
Increment dat index for when another instruction is inserted.
- 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.
- _abc_impl = <_abc._abc_data object at 0x7fd3cea5ae80>
- class Dummy(line: list[str], dat_idx: int, warning: bool = False)
Bases:
InstructionAn object corresponding to a non-implemented element or command.
- __init__(line: list[str], dat_idx: int, warning: bool = False) None
Create the dummy object, raise a warning if necessary.
- _abc_impl = <_abc._abc_data object at 0x7fd3cfa6b640>