camp.generators package

Subpackages

Submodules

Abstract base behavior for all generators.

class camp.generators.base.AbstractWriter(admset, adm, out_path, **kwargs)

Bases: object

Interface for any generator Writer class.

Variables:
  • admset – The AdmSet to use.

  • adm – The specific ADM to generate for.

  • out_path – The output parent path to be used.

file_path() str

Get the path to the file to be generated. This should be derived from out_path.

Returns:

The full path for the file.

write(outfile: TextIO)

Main function for the program. orchestrates calling all helper functions to generate the file text.

Parameters:

outfile – The file object to write to.

class camp.generators.base.CHelperMixin

Bases: object

A mixin class for AbstractWriter to provide C language helpers.

This module creates the c file for the public version of the ADM.

class camp.generators.create_agent_c.Writer(*args, **kwargs)

Bases: AbstractWriter, CHelperMixin

file_path() str

Get the path to the file to be generated. This should be derived from out_path.

Returns:

The full path for the file.

make_std_meta_adm_build_template(coll)
write(outfile: TextIO)

Main function for the program. orchestrates calling all helper functions to generate the file text.

Parameters:

outfile – The file object to write to.

write_includes(outfile)
write_init_constant_function(outfile)
write_init_control_function(outfile)
write_init_edd_function(outfile)
write_init_function(outfile)
write_init_macro_function(outfile)
write_init_metadata_function(outfile)
write_init_op_function(outfile)
write_init_reports_function(outfile)
write_init_tables_function(outfile)
write_init_var_function(outfile)

This module creates the h file for the public portions of an ADM.

class camp.generators.create_gen_h.Writer(admset, adm, out_path, **kwargs)

Bases: AbstractWriter, CHelperMixin

The common header file writer.

file_path() str

Get the path to the file to be generated. This should be derived from out_path.

Returns:

The full path for the file.

format_table_description(descr, desc_col_sz, col_sizes_before, col_sizes_after)
format_table_entry(centered, name, desc, ttype, value)
write(outfile: TextIO)

Main function for the program. orchestrates calling all helper functions to generate the file text.

Parameters:

outfile – The file object to write to.

write_adm_template_documentation(outfile)
write_agent_nickname_definitions(outfile)
write_const_definitions(outfile)
write_ctrl_definitions(outfile)
write_defines(outfile)
write_definition_table_header(fd, definitions_str, value_present)
write_edd_definitions(outfile)
write_endifs(outfile)
write_includes(outfile)
write_initialization_functions(outfile)
write_macro_definitions(outfile)
write_metadata_definitions(outfile)
write_op_definitions(outfile)
write_rptt_definitions(outfile)
write_tblt_definitions(outfile)
write_variable_definitions(outfile)

This module creates the c file for the implementation version of the ADM.

class camp.generators.create_impl_c.Writer(admset, adm, out_path, scrape: bool)

Bases: AbstractWriter, CHelperMixin

The common header file writer.

file_path() str

Get the path to the file to be generated. This should be derived from out_path.

Returns:

The full path for the file.

write(outfile: TextIO)

Main function for the program. orchestrates calling all helper functions to generate the file text.

Parameters:

outfile – The file object to write to.

write_cleanup(outfile)
write_constant_functions(outfile)
write_control_functions(outfile)
write_edd_functions(outfile)
write_metadata_functions(outfile)
write_operator_functions(outfile)
write_setup(outfile)
write_table_functions(outfile)

This module creates the h file for the implementation version of the ADM.

class camp.generators.create_impl_h.Writer(admset, adm, out_path, scrape: bool)

Bases: AbstractWriter, CHelperMixin

The common header file writer.

file_path() str

Get the path to the file to be generated. This should be derived from out_path.

Returns:

The full path for the file.

write(outfile: TextIO)

Main function for the program. orchestrates calling all helper functions to generate the file text.

Parameters:

outfile – The file object to write to.

write_collect_functions(outfile)
write_constant_functions(outfile)
write_control_functions(outfile)
write_defines(outfile)
write_endifs(outfile)
write_includes(outfile)
write_metadata_functions(outfile)
write_operator_functions(outfile)
write_table_functions(outfile)

This module creates the c file for the manager implementation of the ADM.

class camp.generators.create_mgr_c.Writer(*args, **kwargs)

Bases: AbstractWriter, CHelperMixin

file_path() str

Get the path to the file to be generated. This should be derived from out_path.

Returns:

The full path for the file.

write(outfile: TextIO)

Main function for the program. orchestrates calling all helper functions to generate the file text.

Parameters:

outfile – The file object to write to.

write_includes(outfile)
write_init_constants(outfile)
write_init_controls_function(outfile)
write_init_edd_function(outfile)
write_init_function(outfile)
write_init_macros(outfile)
write_init_metadata(outfile)
write_init_ops(outfile)
write_init_reports(outfile)
write_init_tables(outfile)
write_init_variables_function(outfile)
camp.generators.create_mgr_c.make_add_parms_str(parms)

This module creates PGSQL or MySQL scripts to populate the manager database.

class camp.generators.create_sql.Writer(admset, adm, out_path, dialect)

Bases: AbstractWriter

The SQL file writer.

Parameters:

dialect – Choice of the SQL dialect to generate.

DIALECTS = {'mysql', 'pgsql'}
add_to_dockerfile(rel_path_sql)
add_to_setup_mysql(rel_path_sql)
body_post()

Generate liens after the SQL body.

body_pre()

Genreate lines before the SQL body.

create_insert_ac_id_template(obj_type, description_format='{}')
create_insert_formal_parmspec_templates(desc_template='{}')
create_insert_obj_metadata_template(obj_type)

format with 0=object type enum, 1={} (to be filled by caller), 2=highlevel namespace, 3={} (to be filled by caller)

create_insert_tnvc_templates(obj_type, num_entries)
file_path() str

Get the path to the file to be generated. This should be derived from out_path.

Returns:

The full path for the file.

handle_report_fp_ap(item, lines, report_id)

Helper function to handle creation of stored procedures for the fps and aps within the reports templates in the ADM

Parameters:
  • item – definition object to produce the stored procedures for.

  • lines – The lines array to add to

Returns:

a string that is a concatenation of all of the stored procedures necessary for the definition’s aps and fps, to be written to the SQL file by the caller.

make_definition_ids(item)
make_fp_id(obj_id)
make_sql_ids(ari, define=True)

Generate a tuple of the (object id, definition id, actual_id) for a given object. IDs are similar to ARI strings in c/h code, but use only a substring of the ari, splitting it at the first instance of an underscore. This is in order to help keep variable names under 64 characters for SQL.

Parameters:
  • ari – The augmented ARI text.

  • define – If this use is defining the SQL variables.

Returns:

The tuple of IDs.

write(outfile: TextIO)

Main function for the program. orchestrates calling all helper functions to generate the file text.

Parameters:

outfile – The file object to write to.

write_const_functions()

Genreate lines for all of the CONSTs in the ADM

write_ctrl_functions()

Genreate lines for all of the CTRLs in the ADM

write_edd_functions()

Genreate lines for all of the EDDs in the ADM

write_gen_const_functions(objects, coll)

Helper function for the META and CONST objects to allow code reuse since they use the same stored procedures.

Genreate lines for all of the passed objects.

Parameters:
  • objects – list of objects (CONSTs or METAs) to write the stored procedures for

  • coll – type of collection (cs.CONST or cs.META)

write_mac_functions()

Genreate lines for all of the MACs in the ADM

write_mdat_functions()

Genreate lines for all of the MDATs in the ADM

write_metadata_function()

Genreate lines for the ADM metadata

write_oper_functions()

Genreate lines for all of the OPERs in the ADM

write_rptt_functions()

Genreate lines for all of the RPTTs in the ADM

write_setup()

Genreate lines for the introductory material for the sql file

write_tblt_functions()

Genreate lines for all of the TBLTs in the ADM

write_var_functions()

Genreate lines for all of the VARs in the ADM

camp.generators.create_sql.escape_description_sql(val)