line module

Define an object corresponding to a single line of the .dat.

class DatLine(line: str, idx: int)

Bases: object

Hold a single line of the .dat file.

_original_line

Line in the .dat given as a user-input.

Type:

str

idx

Position in the .dat file.

Type:

int

personalized_name

The name given by the user in the .dat. The default is None.

Type:

str | None, optional

weight

The weight of the diagnostic. The default is None.

Type:

float | None, optional

splitted

The line divided into a list of arguments. It is used by LightWin to instantiate the Instruction. Note that the name and the weight of the object are not present to keep the position of other arguments the same. To integrate them, call splitted_full.

Type:

list[str]

__init__(line: str, idx: int) None

Instantiate the object.

__str__() str

Do the same thing as __repr__ for now.

_parse_line(line: str) None

Parse the line into its components.

property instruction: str

Return the command or element name.

Useful for Instruction instantiation.

property line: str

Reconstruct the line (which may have changed since creation).

property splitted_full: list[str]

Give splitted line with name and weight.

property n_args: int

Give number of arguments contained in line.

change_argument(value: Any, position: int) None

Change value of an argument.

append_argument(value: Any) None

Append an argument to the line.

_split_named_elements(elements: Collection[str]) list[str]

Split elements into named and unnamed components.

_split_weighted_elements(elements: list[str]) list[str]

Split elements with weights.

slice_dat_line(line: str) list[str]

Parse a line from a .dat file into meaningful parts.

_is_a_path_instruction(line: str) bool

Detect if this is a path instruction.