dat_files module

Define functions to load, modify and create DAT structure files.

Todo

Insert line skip at each section change in the output.dat

dat_filecontent_from_file(dat_path, *, keep='none', filter_func=None, instructions_to_insert=())[source]

Load the dat file and convert it into a list of lines.

Parameters:
  • dat_path (Path) – Filepath to the DAT file, as understood by TraceWin.

  • keep (Literal['none', 'comments', 'all'], default: 'none') – To determine which un-necessary lines in the dat file should be kept.

  • filter_func (Callable[[DatLine], bool] | None, default: None) – You can provide your own filters here. Takes precedence over keep.

  • instructions_to_insert (Collection[Instruction | DatLine], default: ()) – Some elements or commands that are not present in the DAT file but that you want to add. The default is an empty tuple.

Return type:

list[DatLine]

Returns:

List containing all the lines of dat_path.

_filter_lines(dat_filecontent, keep='none', filter_func=None)[source]

Remove some DatLine from dat_filecontent.

Parameters:
  • dat_filecontent (Sequence[DatLine]) – Content loaded from the DAT file.

  • keep (Literal['none', 'comments', 'all'], default: 'none') – To determine which un-necessary lines in the dat file should be kept. The default is 'none'.

  • filter_func (Callable[[DatLine], bool] | None, default: None) – You can provide your own filters here. Takes precedence over keep.

Return type:

list[DatLine]

Returns:

Content of the DAT file without undesirable content.

_insert_instructions(dat_filecontent, instructions_to_insert=())[source]

Insert the desired instructions in the dat_filecontent.

Parameters:
Return type:

None

dat_filecontent_from_smaller_list_of_elements(original_instructions, elts)[source]

Create a DAT with only elements of elts (and concerned commands).

Properties of the FIELD_MAP, i.e. amplitude and phase, remain untouched.

Parameters:
Return type:

tuple[list[DatLine], list[Instruction]]

_is_needed_element(instruction, indexes_to_keep)[source]

Tell if the instruction is an element that we must keep.

Parameters:
Return type:

bool

_is_useful_command(instruction, indexes_to_keep)[source]

Tell if the current command has an influence on our elements.

Parameters:
Return type:

bool

export_dat_filecontent(dat_filecontent, dat_path)[source]

Save the content of the updated dat to a DAT.

Parameters:
Return type:

None