4.1. configuration generation module

class configs_generator.confGen.ConfGen(db=None, template_file=None, output_file='output.txt', xls_db=None, xls_db_sheet='tables', var_db=None, var_db_sheet='var', confGen_minimal=False, find_column_name='FIND', replace_column_name='REPLACE', repeat_starter='REPEAT EACH', repeat_stopper='REPEAT STOP', condition_starter='GOAHEAD FOR', condition_stopper='GOAHEAD END', nested_section_var_identifier='PARENT')

Bases: object

create an object by providing necessary details to generate configuration Mandatory inputs are template_file, db

deprication_warning()
generate()

Check Template consistency and start execution to generate config

input_check()

check for mandatory inputs

is_template_variried()

sequence of checks to validate the conditions consistency in template. Errored Template can cause infinite loop in execution. raises exception if any error or returns True

template_conditions_count_check()

template check step 2. count of conditions and condition closures matching

template_file_type_check()

template check step 1. File type verification (.txt)

template_nesting_condition_check()

template check step 3. nested conditions closure check to avoid infinite loop

class configs_generator.confGen.Read(section_starter, section_stopper, var_db_columns, xls_db_sheet)

Bases: object

database(xls_db)
dataframes(xls_db)

read Excel sheets and store it in Dictionary

dataframes_depricated(dataframes)

Depricated way of reading sheets. To be Remove in next version

read_temporary_template(template_file)

Reads provided template file, generate sections in the template

template(template_file)
class configs_generator.confGen.Replicate(section_dict, dataframes, confGen_minimal=False)

Bases: object

Replicate section configs using database provided in dataframes.

get_section_dataframe(df_condition)

returns filtered dataframe for given condition

get_table_line_vars(RowData)

data dictionary for a single row

go_thru_section_list()

Entry point for sections

initial_Go()

start parent section/i.e. file

logic_line_to_df_condition(logic_line)

convert condition to pandas dataframe condition

nested_section_var_identifier = 'PARENT.'
property output
replicate_for_data()

Go thru each line of data (data frame), and update configs in that section

start()

Executes the replication

update_condition_for_cf_var(logic_line)

update condition line with carried forwarded Nested Section Variable value. –>updated condition (str)

update_config_section(row)

Add config with updates for given one row

updated_line(line, RowData, header)
class configs_generator.confGen.Section(template_name, section_starter, section_stopper)

Bases: object

get(f, logic_line)

initiates the of section

read_lines(f)

lines inside of a section

configs_generator.confGen.random_text_file(source_file, temporary_prefix)

create a duplicate of source text file with random name using given prefix.

configs_generator.confGen.replace_var_candidates(temporary_template, var_db_df, var_db_columns)

update find/replace pairs in temporary template file

configs_generator.confGen.section_type(line, section_starter)

checks section type in line and returns tuple with details if section is conditional/repeatative