ssg.components module
Common functions for processing Components in SSG
- class ssg.components.Component(filepath)[source]
Bases:
objectA class to represent a component. With regards to the content, a component usually represents a piece of software.
- name
The name of the component.
- Type:
str
- rules
A list of rules associated with the component.
- Type:
list
- packages
A list of packages associated with the component.
- Type:
list
- templates
A list of templates associated with the component. Defaults to an empty list.
- Type:
list, optional
- groups
A list of groups associated with the component. Defaults to an empty list.
- Type:
list, optional
- changelog
A list of changelog entries for the component. Defaults to an empty list.
- Type:
list, optional
- ssg.components.get_rule_to_components_mapping(components)[source]
Generates a mapping from rule IDs to component names.
- Parameters:
components (dict) – A dictionary where the keys are component names and the values are component objects. Each component object is expected to have a ‘rules’ attribute (a list of rule IDs) and a ‘name’ attribute (the name of the component).
- Returns:
- A dictionary where the keys are rule IDs and the values are lists of component names
that include the corresponding rule ID.
- Return type:
dict
- ssg.components.group_component_mapping(components)[source]
Groups components by their associated groups.
- Parameters:
components (dict) – A dictionary where keys are component names and values are dictionaries containing component attributes, including a “groups” key.
- Returns:
- A dictionary where keys are group names and values are lists of component names
that belong to each group.
- Return type:
dict
- ssg.components.load(components_dir)[source]
Load components from a specified directory.
- Parameters:
components_dir (str) – The directory path containing component files.
- Returns:
A dictionary where the keys are component names and the values are component objects.
- Return type:
dict
- ssg.components.package_component_mapping(components)[source]
Maps the given components to their respective packages.
- Parameters:
components (dict) – A dictionary where keys are component names and values are component details.
- Returns:
- A dictionary where keys are package names and values are lists of components
associated to those packages.
- Return type:
dict
- ssg.components.rule_component_mapping(components)[source]
Maps the given components to their corresponding rules.
- Parameters:
components (dict) – A dictionary where keys are component names and values are component details.
- Returns:
A dictionary where keys are rule names and values are the corresponding components.
- Return type:
dict
- ssg.components.template_component_mapping(components)[source]
Maps the given components to their corresponding templates.
- Parameters:
components (dict) – A dictionary where keys are component names and values are component details.
- Returns:
- A dictionary where keys are template names and values are lists of components that
use those templates.
- Return type:
dict