ORE Studio 0.0.4
Loading...
Searching...
No Matches
Functions | Variables
src.generator Namespace Reference

Functions

 load_data (data_dir)
 
 format_comment_block (text, lang='sql')
 
 generate_license_with_header (license_text, modeline_info, lang='sql')
 
 render_template (template_path, data)
 
 get_template_mappings ()
 
 get_schema_template_mappings ()
 
 is_entity_schema_model (model_filename)
 
 is_entity_data_model (model_filename)
 
 is_domain_entity_model (model_filename)
 
 is_junction_model (model_filename)
 
 get_model_type (model_filename)
 
 load_profiles (base_dir)
 
 snake_to_pascal (snake_str)
 
 resolve_output_path (output_pattern, model_data, model_type)
 
 resolve_profile_templates (profile_name, profiles, model_type=None, resolved=None)
 
 validate_profile_for_model (profile_name, profiles, model_type)
 
 list_profiles (profiles)
 
 get_domain_entity_template_mappings ()
 
 get_junction_template_mappings ()
 
 get_qt_domain_entity_template_mappings ()
 
 get_cpp_domain_entity_template_mappings ()
 
 get_cpp_junction_template_mappings ()
 
 get_populate_template_mappings ()
 
 get_non_iso_currency_template_mappings ()
 
 load_model (model_path)
 
 get_relative_path (abs_path, base_path)
 
 _mark_last_item (data_list)
 
 _format_description_as_comment (description)
 
 _prepare_table_display (cpp_section)
 
 _format_detail_for_doxygen (detail)
 
 _format_columns_for_doxygen (columns)
 
 generate_from_model (model_path, data_dir, templates_dir, output_dir, is_processing_batch=False, prefix=None, target_template=None, target_output=None)
 
 generate_flag_svg (country_code_num)
 
 _resolve_file_references (model_data, model_dir, global_data)
 
 main ()
 

Variables

list CURRENCY_DEFAULTS_POOL
 

Detailed Description

Simple code generator that loads data and applies templates.

Function Documentation

◆ load_data()

load_data (   data_dir)
Load all data files from the data directory.

Args:
    data_dir (str): Path to the data directory

Returns:
    dict: Dictionary containing loaded data
Here is the caller graph for this function:

◆ format_comment_block()

format_comment_block (   text,
  lang = 'sql' 
)
Format text as a comment block with language-specific syntax.

Args:
    text (str): Text to format as comments
    lang (str): Programming language for comment syntax

Returns:
    str: Formatted comment block

◆ generate_license_with_header()

generate_license_with_header (   license_text,
  modeline_info,
  lang = 'sql' 
)
Generate a license comment block with modeline and copyright header.

Args:
    license_text (str): Raw license text
    modeline_info (str): Modeline information
    lang (str): Language for comment formatting

Returns:
    str: Complete license comment block with header
Here is the caller graph for this function:

◆ render_template()

render_template (   template_path,
  data 
)
Render a mustache template with the provided data.

Args:
    template_path (str): Path to the template file
    data (dict): Data to use for rendering

Returns:
    str: Rendered template content
Here is the caller graph for this function:

◆ get_template_mappings()

get_template_mappings ( )
Define the mapping between model filenames and their corresponding templates.

Returns:
    dict: Mapping of model filenames to lists of template names
Here is the caller graph for this function:

◆ get_schema_template_mappings()

get_schema_template_mappings ( )
Define the mapping for entity schema templates.

Returns:
    list: List of tuples (template_name, output_suffix) for schema generation
Here is the caller graph for this function:

◆ is_entity_schema_model()

is_entity_schema_model (   model_filename)
Check if a model file is an entity schema model.

Args:
    model_filename (str): The model filename

Returns:
    bool: True if this is an entity schema model
Here is the caller graph for this function:

◆ is_entity_data_model()

is_entity_data_model (   model_filename)
Check if a model file is an entity data model (for populate scripts).

Args:
    model_filename (str): The model filename

Returns:
    bool: True if this is an entity data model
Here is the caller graph for this function:

◆ is_domain_entity_model()

is_domain_entity_model (   model_filename)
Check if a model file is a domain entity model.

Args:
    model_filename (str): The model filename

Returns:
    bool: True if this is a domain entity model
Here is the caller graph for this function:

◆ is_junction_model()

is_junction_model (   model_filename)
Check if a model file is a junction table model.

Args:
    model_filename (str): The model filename

Returns:
    bool: True if this is a junction table model
Here is the caller graph for this function:

◆ get_model_type()

get_model_type (   model_filename)
Determine the model type from the filename.

Args:
    model_filename (str): The model filename

Returns:
    str: The model type ('domain_entity', 'junction', 'schema', 'data', or 'unknown')
Here is the caller graph for this function:

◆ load_profiles()

load_profiles (   base_dir)
Load profile definitions from profiles.json.

Args:
    base_dir (Path): Base directory of the codegen project

Returns:
    dict: Dictionary of profile definitions
Here is the caller graph for this function:

◆ snake_to_pascal()

snake_to_pascal (   snake_str)
Convert a snake_case string to PascalCase.

Args:
    snake_str (str): Snake case string (e.g., "dataset_bundle")

Returns:
    str: PascalCase string (e.g., "DatasetBundle")
Here is the caller graph for this function:

◆ resolve_output_path()

resolve_output_path (   output_pattern,
  model_data,
  model_type 
)
Resolve placeholders in an output path pattern.

Args:
    output_pattern (str): Output path pattern with placeholders
    model_data (dict): The loaded model data
    model_type (str): The model type ('domain_entity', 'junction', etc.)

Returns:
    str: Resolved output path
Here is the caller graph for this function:

◆ resolve_profile_templates()

resolve_profile_templates (   profile_name,
  profiles,
  model_type = None,
  resolved = None 
)
Resolve all templates for a profile, including any included profiles.

Args:
    profile_name (str): Name of the profile to resolve
    profiles (dict): Dictionary of all profile definitions
    model_type (str): The model type for filtering templates
    resolved (set): Set of already resolved profile names (for cycle detection)

Returns:
    list: List of template info dicts with 'template' and optional 'output' keys
Here is the caller graph for this function:

◆ validate_profile_for_model()

validate_profile_for_model (   profile_name,
  profiles,
  model_type 
)
Check if a profile is compatible with a model type.

Args:
    profile_name (str): Name of the profile
    profiles (dict): Dictionary of all profile definitions
    model_type (str): The model type

Returns:
    tuple: (is_valid, error_message)
Here is the caller graph for this function:

◆ list_profiles()

list_profiles (   profiles)
Print a formatted list of available profiles.

Args:
    profiles (dict): Dictionary of profile definitions
Here is the caller graph for this function:

◆ get_domain_entity_template_mappings()

get_domain_entity_template_mappings ( )
Define the mapping for domain entity schema templates.

Returns:
    list: List of tuples (template_name, output_suffix) for domain entity generation
Here is the caller graph for this function:

◆ get_junction_template_mappings()

get_junction_template_mappings ( )
Define the mapping for junction table schema templates.

Returns:
    list: List of tuples (template_name, output_suffix) for junction table generation
Here is the caller graph for this function:

◆ get_qt_domain_entity_template_mappings()

get_qt_domain_entity_template_mappings ( )
Define the mapping for Qt domain entity templates.

Returns:
    list: List of tuples (template_name, output_dir, output_suffix) for Qt generation
Here is the caller graph for this function:

◆ get_cpp_domain_entity_template_mappings()

get_cpp_domain_entity_template_mappings ( )
Define the mapping for C++ domain entity templates.

Returns:
    list: List of tuples (template_name, output_dir, output_suffix) for C++ generation
Here is the caller graph for this function:

◆ get_cpp_junction_template_mappings()

get_cpp_junction_template_mappings ( )
Define the mapping for C++ junction table templates.

Returns:
    list: List of tuples (template_name, output_dir, output_suffix) for C++ generation
Here is the caller graph for this function:

◆ get_populate_template_mappings()

get_populate_template_mappings ( )
Define the mapping for entity populate templates (per-dataset).

Returns:
    list: List of tuples (template_name, output_prefix, output_suffix) for populate generation
Here is the caller graph for this function:

◆ get_non_iso_currency_template_mappings()

get_non_iso_currency_template_mappings ( )
Define the mapping for non-ISO currency populate templates.

Non-ISO currencies use the shared dq_currencies_artefact_tbl instead of
having their own entity-specific artefact table.

Returns:
    list: List of tuples (template_name, output_prefix, output_suffix) for populate generation
Here is the caller graph for this function:

◆ load_model()

load_model (   model_path)
Load a model from the specified path.

Args:
    model_path (str or Path): Path to the model file

Returns:
    dict: The loaded model data
Here is the caller graph for this function:

◆ get_relative_path()

get_relative_path (   abs_path,
  base_path 
)
Get the relative path of abs_path from base_path.

Args:
    abs_path (Path): Absolute path
    base_path (Path): Base path to calculate relative path from

Returns:
    str: Relative path string
Here is the caller graph for this function:

◆ _mark_last_item()

_mark_last_item (   data_list)
protected
Mark the last item in a list of dictionaries with a 'last' flag.

Args:
    data_list (list): List to process
Here is the caller graph for this function:

◆ _format_description_as_comment()

_format_description_as_comment (   description)
protected
Format a multi-line description as SQL comment block content.

Adds ' * ' prefix to each line after the first, handling empty lines
as ' *' (just asterisk).

Args:
    description (str): Multi-line description text

Returns:
    str: Formatted description with comment prefixes
Here is the caller graph for this function:

◆ _prepare_table_display()

_prepare_table_display (   cpp_section)
protected
Prepare table_display items by adding iterator_var to each item.

Mustache can't access parent context variables from within a loop,
so we add the iterator_var to each table_display item.

Args:
    cpp_section (dict): The 'cpp' section of the model
Here is the caller graph for this function:

◆ _format_detail_for_doxygen()

_format_detail_for_doxygen (   detail)
protected
Format a multi-line detail string for doxygen comments.

Adds '     * ' prefix to continuation lines.

Args:
    detail (str): Multi-line detail text

Returns:
    str: Formatted detail with proper doxygen prefixes
Here is the caller graph for this function:

◆ _format_columns_for_doxygen()

_format_columns_for_doxygen (   columns)
protected
Format detail fields in columns for doxygen comments.

Args:
    columns (list): List of column dictionaries
Here is the caller graph for this function:

◆ generate_from_model()

generate_from_model (   model_path,
  data_dir,
  templates_dir,
  output_dir,
  is_processing_batch = False,
  prefix = None,
  target_template = None,
  target_output = None 
)
Generate output files from a model using the appropriate templates.

Args:
    model_path (str or Path): Path to the model file
    data_dir (Path): Path to the data directory
    templates_dir (Path): Path to the templates directory
    output_dir (Path): Path to the output directory
    is_processing_batch (bool): Flag to indicate if we're already processing a batch
    prefix (str): Optional prefix for output filenames
    target_template (str): Optional override for the template to use
    target_output (str): Optional override for the output filename
Here is the caller graph for this function:

◆ generate_flag_svg()

generate_flag_svg (   country_code_num)
Generate a deterministic SVG flag based on a country code number.

Args:
    country_code_num (int or str): A number representing the country code

Returns:
    str: SVG string for the flag
Here is the caller graph for this function:

◆ _resolve_file_references()

_resolve_file_references (   model_data,
  model_dir,
  global_data 
)
protected
Resolve file references in the model data by reading content from external files.

Args:
    model_data (dict or list): The model data that may contain file references
    model_dir (Path): Directory where the model file is located
    global_data (dict): Global data dictionary to update with resolved content
Here is the caller graph for this function:

◆ main()

main ( )
Main function to run the code generator.
Here is the caller graph for this function:

Variable Documentation

◆ CURRENCY_DEFAULTS_POOL

list CURRENCY_DEFAULTS_POOL
Initial value:
1= [
2 {'symbol': '$', 'fraction_symbol': '¢', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': '$#,##0.00', 'currency_type': 'fiat.emerging'},
3 {'symbol': '€', 'fraction_symbol': 'c', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': '€#,##0.00', 'currency_type': 'fiat.major'},
4 {'symbol': '£', 'fraction_symbol': 'p', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': '£#,##0.00', 'currency_type': 'fiat.major'},
5 {'symbol': '¥', 'fraction_symbol': '', 'fractions_per_unit': 0, 'rounding_type': 'Closest', 'rounding_precision': 0, 'format': '¥#,##0', 'currency_type': 'fiat.emerging'},
6 {'symbol': 'kr', 'fraction_symbol': 'ø', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': 'kr #,##0.00', 'currency_type': 'fiat.major'},
7 {'symbol': 'zł', 'fraction_symbol': 'gr', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': '#,##0.00 zł', 'currency_type': 'fiat.emerging'},
8 {'symbol': '₹', 'fraction_symbol': 'p', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': '₹#,##0.00', 'currency_type': 'fiat.emerging'},
9 {'symbol': 'د.إ', 'fraction_symbol': 'ف', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': 'د.إ#,##0.00', 'currency_type': 'fiat.emerging'},
10 {'symbol': 'R', 'fraction_symbol': 'c', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': 'R#,##0.00', 'currency_type': 'fiat.emerging'},
11 {'symbol': 'ƒ', 'fraction_symbol': '¢', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': 'ƒ#,##0.00', 'currency_type': 'fiat.emerging'},
12 {'symbol': 'د.ك', 'fraction_symbol': 'ف', 'fractions_per_unit': 1000, 'rounding_type': 'Closest', 'rounding_precision': 3, 'format': 'د.ك#,##0.000', 'currency_type': 'fiat.emerging'},
13 {'symbol': 'S/', 'fraction_symbol': '¢', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': 'S/#,##0.00', 'currency_type': 'fiat.emerging'},
14 {'symbol': '฿', 'fraction_symbol': 'ส', 'fractions_per_unit': 100, 'rounding_type': 'Closest', 'rounding_precision': 2, 'format': '฿#,##0.00', 'currency_type': 'fiat.emerging'},
15]