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 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.
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.
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 lines after the SQL body.
- body_pre()
Generate 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()
Generate lines for all of the CONSTs in the ADM
- write_ctrl_functions()
Generate lines for all of the CTRLs in the ADM
- write_edd_functions()
Generate 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.
Generate 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_mdat_functions()
Generate lines for all of the MDATs in the ADM
- write_metadata_function()
Generate lines for the ADM metadata
- write_oper_functions()
Generate lines for all of the OPERs in the ADM
- write_setup()
Generate lines for the introductory material for the sql file
- write_var_functions()
Generate lines for all of the VARs in the ADM
- camp.generators.create_sql.escape_description_sql(val)
- camp.generators.create_sql.yang_to_sql(identifier)