FOSSology  4.5.1
Open Source License Compliance by Open Source Software
FoScanner.SpdxReport.SpdxReport Class Reference
Collaboration diagram for FoScanner.SpdxReport.SpdxReport:
Collaboration graph

Public Member Functions

def __init__ (self, CliOptions cli_options, Scanners scanner)
 
def write_report (self, str file_name)
 
def finalize_document (self)
 

Public Attributes

 cli_options
 
 scanner
 

Private Member Functions

LicenseExpression __get_license_or_ref (self, str lic)
 
def __add_license_file (self, Package package, ScanResultList scan_result)
 
File __get_spdx_file (self, ScanResultList scan_result, Package package)
 
def __add_copyright_file (self, Package package, ScanResultList copyright_result)
 
None __create_packages (self)
 
Package __get_package_for_component (self, dict component)
 
None __create_license_files (self)
 
None __create_copyright_files (self)
 
None __create_license_file_from_component (self, dict component, Package package)
 
None __create_copyright_file_from_component (self, dict component, Package package)
 
None __add_files_to_document (self)
 
None __add_extracted_licenses (self)
 
None __update_package_verification_code (self)
 
PackageVerificationCode|None __calculate_verification_code (self, str package_spdx_id)
 

Static Private Member Functions

tuple[str, str, str] __get_file_info (ScanResultList scan_result)
 
str __get_file_spdx_id (str sha256_hash, str pkg_name)
 
str __get_package_spdx_id (dict component)
 

Private Attributes

 _allowed_licenses_set
 
 _spdx_lic_cache
 

Detailed Description

Handle SPDX reports.

:ivar cli_options: CliOptions object
:ivar report_files: Dictionary of SPDX files with SPDX ID as key
:ivar license_package_set: Set of licenses found in package
:ivar creation_info: Report creation info
:ivar document: Report document
:ivar package: Report package
:ivar scanner: Scanners object

Definition at line 31 of file SpdxReport.py.

Constructor & Destructor Documentation

◆ __init__()

def FoScanner.SpdxReport.SpdxReport.__init__ (   self,
CliOptions  cli_options,
Scanners  scanner 
)
:param cli_options: CliOptions to use
:param scanner:     Scanners to use

Definition at line 44 of file SpdxReport.py.

Member Function Documentation

◆ __add_copyright_file()

def FoScanner.SpdxReport.SpdxReport.__add_copyright_file (   self,
Package  package,
ScanResultList   copyright_result 
)
private
Add scan result from copyright agent. If the file does not exist, creates a
new one.

:param copyright_result: Scan result from copyright scanner.

Definition at line 215 of file SpdxReport.py.

◆ __add_license_file()

def FoScanner.SpdxReport.SpdxReport.__add_license_file (   self,
Package  package,
ScanResultList  scan_result 
)
private
Add scan result from license scanner to report.

:param package: Package to which the file belongs.
:param scan_result: Scan result from license scanner.

Definition at line 130 of file SpdxReport.py.

◆ __calculate_verification_code()

PackageVerificationCode | None FoScanner.SpdxReport.SpdxReport.__calculate_verification_code (   self,
str   package_spdx_id 
)
private
Calculate package verification code for the list of checksums and return it.

:param package_spdx_id: Package SPDX ID to calculate the verification
code for.
:return: Package Verification Code based on SPDX specification.

Definition at line 436 of file SpdxReport.py.

◆ __get_file_info()

tuple[str, str, str] FoScanner.SpdxReport.SpdxReport.__get_file_info ( ScanResultList  scan_result)
staticprivate
Get different hash for the file in scan result.

:param scan_result: Scan result from scanners.
:return: Tuple of md5, sha1 and sha256 checksums.

Definition at line 232 of file SpdxReport.py.

◆ __get_file_spdx_id()

str FoScanner.SpdxReport.SpdxReport.__get_file_spdx_id ( str  sha256_hash,
str  pkg_name 
)
staticprivate
Generate SPDX ID for file in scan result.

:param sha256_hash: SHA 256 checksum of the file
:param pkg_name: Package to which the file belongs.
:return: SPDX ID for the file.

Definition at line 250 of file SpdxReport.py.

◆ __get_package_for_component()

Package FoScanner.SpdxReport.SpdxReport.__get_package_for_component (   self,
dict  component 
)
private
For a given component, create a package and add it to the list.

:param component: Component to create package for.
:return: Create or get existing package.

Definition at line 342 of file SpdxReport.py.

◆ __get_package_spdx_id()

str FoScanner.SpdxReport.SpdxReport.__get_package_spdx_id ( dict  component)
staticprivate
Generate SPDX ID for a package/component.

:param component: Package/component to get SPDX ID for.
:return: SPDX ID for the package.

Definition at line 261 of file SpdxReport.py.

◆ __get_spdx_file()

File FoScanner.SpdxReport.SpdxReport.__get_spdx_file (   self,
ScanResultList  scan_result,
Package   package 
)
private
Create a new SPDX File for given scan result and populate common fields.

:param scan_result: Scan result from scanner.
:param package: Package to which the file belongs.
:return: New SPDX File

Definition at line 170 of file SpdxReport.py.

◆ finalize_document()

def FoScanner.SpdxReport.SpdxReport.finalize_document (   self)
Finalize the document by setting relations between packages and files.
At the same time, add all the licenses from files to the package and
calculate the verification code, without the excluded files.

Definition at line 301 of file SpdxReport.py.

◆ write_report()

def FoScanner.SpdxReport.SpdxReport.write_report (   self,
str  file_name 
)
Validate the document and write the SPDX file.

:param file_name: Location to store the report.

Definition at line 274 of file SpdxReport.py.


The documentation for this class was generated from the following file: