![]() |
FOSSology
4.7.1
Open Source License Compliance by Open Source Software
|


Public Member Functions | |
| def | __init__ (self, CliOptions cli_options, Scanners scanner) |
| def | finalize_document (self) |
| def | write_report (self, str file_name) |
Public Attributes | |
| cli_options | |
| scanner | |
| payload | |
| creation_info | |
| root_package | |
Public Attributes inherited from FoScanner.ReportBase.ReportBase | |
| cli_options | |
| scanner | |
Private Member Functions | |
| def | _deduplicate_creation_info (self, g, rdflib) |
| def | _fixup_rdf_graph (self, g, rdflib) |
| def | _process_component (self, dict component, str parent_pkg_id) |
| def | _resolve_licenses (self, list[str] licenses) |
| def | _get_license_object (self, str lic_id) |
| Package | _get_or_create_dep_package (self, dict component) |
| None | _validate_report (self, str file_name) |
Static Private Member Functions | |
| def | _load_spdx_shacl_model () |
| def | _type_satisfies (existing_types, expected_class, subclass_map) |
| str | _make_base_uri (str doc_name) |
| def | _sanitize_xml_literals (g, rdflib) |
| str | _rdf_format_for_file (str file_name) |
Private Attributes | |
| _rel_idx | |
| _file_idx | |
| _spdx_licensing | |
| _base | |
Static Private Attributes | |
| _XML_INVALID_RE | |
Handle SPDX 3.0 reports. :ivar cli_options: CliOptions object :ivar scanner: Scanners object :ivar payload: spdx_tools Payload holding all SPDX 3.0 elements :ivar root_package: Root Package element for the scanned project :ivar creation_info: Shared CreationInfo for all elements
Definition at line 71 of file Spdx3Report.py.
| def FoScanner.Spdx3Report.Spdx3Report.__init__ | ( | self, | |
| CliOptions | cli_options, | ||
| Scanners | scanner | ||
| ) |
Initialise the SPDX 3.0 report builder. :param cli_options: CliOptions to use :param scanner: Scanners to use
Reimplemented from FoScanner.ReportBase.ReportBase.
Definition at line 82 of file Spdx3Report.py.
|
private |
Merge identical CreationInfo blank nodes into a single named node. The spdx-tools JSON-LD serializer inlines CreationInfo as blank nodes, causing duplication. This replaces all of them with one shared URI node.
Definition at line 279 of file Spdx3Report.py.
|
private |
Return a cached LicenseExpression or CustomLicense for a single ID. For SPDX-listed licenses, creates a LicenseExpression with just the spdx expression string (no full license object needed per the spec). For custom/unknown licenses, creates a CustomLicense with licenseText as required by the SPDX 3.0 spec (minCount=1).
Definition at line 516 of file Spdx3Report.py.
|
private |
Create (or retrieve cached) a dependency Package element.
Definition at line 549 of file Spdx3Report.py.
|
staticprivate |
Load the SPDX SHACL model bundled with spdx-tools. :return: (rdflib.Graph, shacl_path_str)
Definition at line 267 of file Spdx3Report.py.
|
staticprivate |
Generate a unique base URI for the document.
Definition at line 573 of file Spdx3Report.py.
|
private |
Read SCANNER_RESULTS and COPYRIGHT_RESULT from *component* dict, create File elements, and wire CONTAINS relationships.
Definition at line 415 of file Spdx3Report.py.
|
staticprivate |
Determine the rdflib serialization format from a file extension. Uses rdflib's own ``SUFFIX_FORMAT_MAP`` so that new formats are supported automatically without code changes. Falls back to ``json-ld`` for unknown extensions.
Definition at line 604 of file Spdx3Report.py.
|
private |
Resolve a list of license identifiers to the correct SPDX 3.0 model objects. - SPDX-listed licenses → ListedLicense (ExpandedLicensing) - Non-SPDX licenses → CustomLicense with LicenseRef- prefix - Multiple licenses → ConjunctiveLicenseSet (AND semantics) - No licenses → NoAssertionLicense Objects are cached so the same license ID reuses one instance.
Definition at line 495 of file Spdx3Report.py.
|
staticprivate |
Remove characters that are invalid in XML 1.0 from all Literal values. rdflib's RDF/XML serializer writes these characters verbatim, but XML parsers (expat) reject them on re-read, causing 'not well-formed' errors. Only needed for XML-based output formats.
Definition at line 587 of file Spdx3Report.py.
|
staticprivate |
Check whether any of *existing_types* equals *expected_class* or is a known subclass of it (according to *subclass_map*).
Definition at line 403 of file Spdx3Report.py.
|
private |
Validate the written SPDX 3.0 report using pyshacl against the SHACL schema bundled with spdx-tools. Works for any RDF serialization format (Turtle, JSON-LD, RDF/XML, etc.).
Definition at line 615 of file Spdx3Report.py.
| def FoScanner.Spdx3Report.Spdx3Report.finalize_document | ( | self | ) |
Process all scan results (parent + dependencies), create File elements and Relationships, then build the SpdxDocument.
Reimplemented from FoScanner.ReportBase.ReportBase.
Definition at line 161 of file Spdx3Report.py.
| def FoScanner.Spdx3Report.Spdx3Report.write_report | ( | self, | |
| str | file_name | ||
| ) |
Validate and serialize the report to *file_name*. :param file_name: Destination path for the generated report. :raises RuntimeError: If validation or serialization fails.
Reimplemented from FoScanner.ReportBase.ReportBase.
Definition at line 217 of file Spdx3Report.py.
|
staticprivate |
Definition at line 581 of file Spdx3Report.py.