ssg.variables module

ssg.variables.get_variable_files(content_dir: str) List[str][source]

Retrieves all variable files from the specified content root directory.

This function iterates through a predefined list of benchmark directories and collects all variable files within those directories.

Parameters:

content_dir (str) – The root directory containing benchmark directories.

Returns:

A list of paths to all variable files found within the benchmark directories.

Return type:

list

ssg.variables.get_variable_files_in_folder(content_dir: str, subfolder: str) List[str][source]

Retrieve a list of variable files within a specified folder in the project.

Parameters:
  • content_dir (str) – The root directory of the content.

  • subfolder (str) – The folder within the project to search for variable files.

Returns:

A list of paths to variable files found within the specified folder.

Return type:

list

ssg.variables.get_variable_options(content_dir: str, variable_id: str | None = None) Dict[str, Dict[str, str]][source]

Retrieve the options for specific or all variables from the content root directory.

If variable_id is provided, returns options for that variable only. If variable_id is not provided, returns a dictionary of all variables with their options.

Parameters:
  • content_dir (str) – The root directory containing benchmark directories.

  • variable_id (str, optional) – The ID of the variable to retrieve options for. Defaults to None.

Returns:

If variable_id is None, a dictionary where keys are variable IDs and values are

their options. Otherwise, a dictionary of options for the specified variable.

Return type:

dict

ssg.variables.get_variable_property(content_dir: str, variable_id: str, property_name: str) str[source]

Retrieve a specific property of a variable from the content root directory.

Parameters:
  • content_dir (str) – The root directory containing benchmark directories.

  • variable_id (str) – The ID of the variable to retrieve the property for.

  • property_name (str) – The name of the property to retrieve.

Returns:

The value of the specified property for the variable.

Return type:

str

ssg.variables.get_variable_values(content_dir: str, profiles_variables: dict) dict[source]

Update the variables dictionary with actual values for each variable option.

Given a content root directory and a dictionary of variables, this function retrieves the respective options values from variable files and updates the variables dictionary with these values.

Parameters:
  • content_dir (str) – The root directory of the content.

  • profiles_variables (dict) – A dictionary where keys are variable names and values are dictionaries of product-profile pairs.

Returns:

The updated variables dictionary with possible values for each variable.

Return type:

dict

ssg.variables.get_variables_by_products(content_dir: str, products: list) Dict[str, dict][source]

Retrieve variables by products from the specified content root directory.

This function collects profiles for the given products and extracts variables from these profiles. If you already have a list of Profiles obtained by get_profiles_from_products() defined in profiles.py, consider to use get_variables_from_profiles() instead.

Parameters:
  • content_dir (str) – The root directory of the content.

  • products (list) – A list of products to retrieve variables for.

Returns:

A dictionary where keys are variable names and values are dictionaries of

product-profile pairs.

Return type:

dict

ssg.variables.get_variables_from_profiles(profiles: list) Dict[str, Dict[str, str]][source]

Extracts variables from a list of profiles and organizes them into a nested dictionary.

Parameters:

profiles (list) – A list of profile objects, each containing selections and id attributes.

Returns:

A nested dictionary where the first level keys are variable names, the second level

keys are product names, and the third level keys are profile IDs, with the corresponding values being the variable values.

Return type:

dict