FOSSology  4.7.1
Open Source License Compliance by Open Source Software
ReportBase.py
1 #!/usr/bin/env python3
2 
3 # SPDX-FileCopyrightText: © 2026 Siemens AG
4 # SPDX-FileContributor: Shatakshi Tiwari <shatakshi.tiwari@siemens.com>
5 #
6 # SPDX-License-Identifier: GPL-2.0-only
7 
8 """
9 Abstract base class for all report generators.
10 """
11 
12 from abc import ABC, abstractmethod
13 
14 from .CliOptions import CliOptions
15 from .Scanners import Scanners
16 
17 
18 class ReportBase(ABC):
19  """
20  Interface contract for report generators.
21 
22  Every report class must accept ``cli_options`` and ``scanner`` at
23  construction time and implement :meth:`finalize_document` and
24  :meth:`write_report`.
25  """
26 
27  def __init__(self, cli_options: CliOptions, scanner: Scanners):
28  """
29  :param cli_options: Resolved CLI options for the current run.
30  :param scanner: Scanner instance holding scan results.
31  """
32  self.cli_optionscli_options = cli_options
33  self.scannerscanner = scanner
34 
35  @abstractmethod
36  def finalize_document(self) -> None:
37  """
38  Process scan results and assemble the internal document model.
39 
40  Called after all scans have completed but before writing.
41  """
42 
43  @abstractmethod
44  def write_report(self, file_name: str) -> None:
45  """
46  Validate and serialize the report to *file_name*.
47 
48  :param file_name: Destination path for the generated report.
49  :raises RuntimeError: If validation or serialization fails.
50  """
51 
def __init__(self, CliOptions cli_options, Scanners scanner)
Definition: ReportBase.py:27
None write_report(self, str file_name)
Definition: ReportBase.py:44