cfg Reader

class pydiana.scripting.cfg_reader.averagecfg(cfg_file, other_flags='', all=False)[source]

Bases: sequencecfg

Class for dealing with sequences that build average quantites. Made mainly for averagepulse and averagenoise.

find_all_files()[source]

Finds all the files in the .list file

Returns:

List with the files in the list.

find_input_file()[source]

Find input file from the reader.

Returns:

String with the input file

get_calls()[source]

Get all the calls from the cfg.

Returns:

Returns list with all the generated bash calls.

make_diana_call(optional_args=None, exclude=None)[source]

Function for making the diana bash call for this sequence.

Parameters:
  • (str) (optional_args) --

  • (list) (exclude) --

Returns:

True if everything is successfull otherwise False

class pydiana.scripting.cfg_reader.sequencecfg(cfg_file, other_flags='')[source]

Bases: object

compare_vars()[source]

Not sure....

complete_line(line)[source]

Function for completing the line in the cfg by inserting the value of the variable.

Parameters:

(str) (line) --

Returns:

The completed line or None if not successful.

complete_vars()[source]

Function for completing the variable contents.

drop_empty()[source]

Remove empty lines

find_all_substr_occur(line, substr)[source]

Function for finding a substring in a string.

Parameters:
  • (str) (substr) --

  • (str) --

Returns:

List of indexes with the positions in which the substring was found

find_line_value(line, content)[source]

Find value after the '=' sign in a cfg line

Parameters:

(str) (line) --

Returns:

String with the parameter value, the string is empty if the parameter is not found.

find_var_pos_in_line(line)[source]

Utility function for finding variable position in the line of the cfg.

findcfg(cfg)[source]

This function searces the cfg in the DIANA_EXT_INSTALL/cfg and DIANA_INSTALL/cfg folders. If a path is provided (relative or absolute) then the search is not performed

Parameters:

(str) (cfg) --

Return type:

str

Returns:

String with path to cfg. If not Found returns None.

get_calls()[source]

Get all the calls from the cfg.

Returns:

Returns list with all the generated bash calls.

get_core_filename()[source]

Get run formatted for output file

Returns:

None if run is not set else returns the string of the run.

get_input_file()[source]

Get inputfile line from reader of cfg.

Returns:

string containing the input file value.

get_module(name)[source]

Getting a specific module from the cfg.

TODO: probably needs perfecting.

Parameters:

(str) (name) --

Returns:

List containing the lines regarding the module

get_output_file()[source]

Get outputfile line from writer of cfg.

Returns:

string containing the output file value.

get_reader()[source]

Function for getting reader of the cfg.

Returns:

List containing the lines regarding the module

get_run()[source]

Getting run of the cfg

Returns:

run (int) : integer with the run number

get_var(name)[source]

Function for getting the content of a cfg variable

Parameters:

(str) (name) --

Returns:

Value of the parameter or None if the parameter is not found

get_writer()[source]

Function for getting writer of the cfg.

Returns:

List containing the lines regarding the module

loadfile()[source]

Function for loading cfg file content

make_diana_call(optional_args=None)[source]

Function for making the diana bash call for this sequence.

Parameters:

(str) (optional_args) --

Returns:

True if everything is successfull otherwise False

read_framework_vars()[source]

This function reads the cfg parameters

read_vars()[source]

This function reads all the variables in the cfg.

read_vars_in_line(line)[source]

Utility function for reading all variables in the line of the cfg.

remove_comments()[source]

Remove comments from the cfg

remove_newline()[source]

This function removes the new line at the end of each line from the file

remove_spaces()[source]

This function removes spaces from the file content

remove_tabs()[source]

This function removes the new line at the end of each line from the file

run_cfg()[source]

Function for running the cfg bash call using subprocess.

Returns:

The result of the diana call

sequence_name()[source]

Read sequence name from cfg

Return type:

bool

Returns:

Returns True if the name was found else returns False

set_run(run=None)[source]

Setting run for the cfg

Parameters:

(int) (run) --

set_var(name, value)[source]

Function for setting a single cfg variable.

Parameters:
  • (str) (name) --

  • (undefined) (value) --

Returns
:

True if everything goes well else returns False

set_vars(params)[source]

Function for setting the cfg parameters

Parameters:

(dict) (params) --

Returns:

True if everything goes well else returns False