line module

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

class DatLine(line, idx)[source]

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]

Parameters:
__init__(line, idx)[source]

Instantiate the object.

Parameters:
__str__()[source]

Do the same thing as __repr__ for now.

Return type:

str

_parse_line(line)[source]

Parse the line into its components.

Parameters:

line (str)

Return type:

None

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, position)[source]

Change value of an argument.

Parameters:
Return type:

None

append_argument(value)[source]

Append an argument to the line.

Parameters:

value (Any)

Return type:

None

_split_named_elements(elements)[source]

Split elements into named and unnamed components.

Parameters:

elements (Collection[str])

Return type:

list[str]

_split_weighted_elements(elements)[source]

Split elements with weights.

Parameters:

elements (list[str])

Return type:

list[str]

slice_dat_line(line)[source]

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

Parameters:

line (str)

Return type:

list[str]

_is_a_path_instruction(line)[source]

Detect if this is a path instruction.

Parameters:

line (str)

Return type:

bool