line module

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

class DatLine(line, idx, original_line=None)[source]

Bases: object

Hold a single line of the DAT file.

Parameters:
  • _original_line – Line in the DAT given as a user-input.

  • idx (int) – Position in the DAT file.

  • personalized_name – The name given by the user in the DAT.

  • weight – The weight of the diagnostic.

  • 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.

  • line (str)

  • original_line (str | None, default: None)

__init__(line, idx, original_line=None)[source]

Instantiate the object.

Parameters:
  • line (str) – The corresponding line in the DAT file.

  • idx (int) – The corresponding position in the DAT file.

  • original_line (str | None, default: None) – The corresponding line in the DAT file. Should be provided only when creating a fake element. CUrrently, this is used only for the SuperposeMap. The default is None

Return type:

None

__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