assets_guardian.core.reporting.excel.sheets_builder

Classes

GenericSheetBuilder(source_name,Β ...)

Generic Excel sheet builder driven by configuration metadata.

class assets_guardian.core.reporting.excel.sheets_builder.GenericSheetBuilder(source_name: str, instance_id: str, rules_file_path: str | Path)[source]

Bases: ISheetBuilder

Generic Excel sheet builder driven by configuration metadata.

Variables:

source_name (str) – Unique name of the source (e.g., β€˜gitlab’).

Initializes the generic sheet builder.

Parameters:
  • source_name – Technical name of the source plugin.

  • rules_file_path – Absolute or relative path to the JSON rules file.

build(worksheet: Any, data: Any, preserved: Any, rules: Any) None[source]

Builds the Excel sheet by applying filters and mappings from the rules file.

Parameters:
  • worksheet – The Excel worksheet (ExcelWorksheet).

  • data – Collection data (source, instance) -> CollectorResult.

  • preserved – Manual data indexed by its primary key.

  • rules – Column definition (list of dictionaries).

get_rules() dict[str, list[dict[str, Any]]][source]

Returns the formatting rules in the format expected by the ExcelWriter.

This method extracts only the list of columns for each sheet.

Returns:

Dictionary of rules per sheet.

Return type:

dict[str, list[dict[str, Any]]]

property preserved_columns: dict[str, dict[str, list[str]]]

Dynamically defines the columns to preserve from the configuration.

Returns:

Preservation configuration.

Return type:

dict[str, dict[str, list[str]]]

property sheet_names: list[str]

Returns the list of Excel sheet names defined in the rules.

Returns:

List of sheet names.

Return type:

list[str]