reuse.report module
Module that contains reports about files and projects for linting.
-
reuse.report.ENABLE_PARALLEL = True
This variable exists to be able to override parallelisation. If set to
False, generating FileReport.generate() will not use
parallelisation.
-
class reuse.report.ProjectReportSubsetProtocol(*args, **kwargs)[source]
Bases: Protocol
A Protocol that defines a subset of functionality of
ProjectReport, implemented by ProjectSubsetReport.
-
path: str | PathLike[str]
-
read_errors: set[Path]
-
file_reports: set[FileReport]
-
property missing_licenses: dict[str, set[Path]]
Files which refer to a license which do not exist in the LICENSES/
directory.
-
property invalid_spdx_expressions: dict[Path, set[str]]
Invalid expressions by file.
-
property files_without_licenses: set[Path]
Set of paths that have no licensing information.
-
property files_without_copyright: set[Path]
Set of paths that have no copyright information.
-
property is_compliant: bool
Whether the report subset is compliant with the REUSE Spec.
-
class reuse.report.ProjectReport(do_checksum: bool = True)[source]
Bases: object
Object that holds linting report about the project.
-
to_dict_lint() → dict[str, Any][source]
Collects and formats data relevant to linting from report and returns
it as a dictionary.
- Returns:
Dictionary containing data from the ProjectReport object.
-
bill_of_materials(creator_person: str | None = None, creator_organization: str | None = None) → str[source]
Generate a bill of materials from the project.
See https://spdx.org/specifications.
-
classmethod generate(project: Project, do_checksum: bool = True, multiprocessing: bool = True, add_license_concluded: bool = False) → ProjectReport[source]
Generate a ProjectReport from a Project.
- Parameters:
project – The Project to lint.
do_checksum – Generate a checksum of every file. If this is
False, generate a random checksum for every file.
multiprocessing – Whether to use multiprocessing.
add_license_concluded – Whether to aggregate all found SPDX
expressions into a concluded license.
-
property used_licenses: set[str]
Set of license identifiers that are found in file reports.
-
property bad_licenses: dict[str, Path]
Licenses in LICENSES/ which are not valid SPDX licenses.
-
property deprecated_licenses: set[str]
Licenses whose SPDX License identifier has been deprecated.
-
property unused_licenses: set[str]
Set of license identifiers that are not found in any file report.
-
property missing_licenses: dict[str, set[Path]]
Files which refer to a license which do not exist in the LICENSES/
directory.
-
property invalid_spdx_expressions: dict[Path, set[str]]
Invalid expressions by file.
-
property files_without_licenses: set[Path]
Set of paths that have no licensing information.
-
property files_without_copyright: set[Path]
Set of paths that have no copyright information.
-
property is_compliant: bool
Whether the report is compliant with the REUSE Spec.
-
property recommendations: list[str]
Generate help for next steps based on found REUSE issues
-
class reuse.report.ProjectSubsetReport[source]
Bases: object
Like a ProjectReport, but for a subset of the files using a
subset of features.
-
classmethod generate(project: Project, subset_files: Collection[str | PathLike[str]], multiprocessing: bool = True) → ProjectSubsetReport[source]
Generate a ProjectSubsetReport from a Project.
- Parameters:
project – The Project to lint.
subset_files – Only lint the files in this list.
multiprocessing – Whether to use multiprocessing.
-
property missing_licenses: dict[str, set[Path]]
Files which refer to a license which do not exist in the LICENSES/
directory.
-
property invalid_spdx_expressions: dict[Path, set[str]]
Invalid expressions by file.
-
property files_without_licenses: set[Path]
Set of paths that have no licensing information.
-
property files_without_copyright: set[Path]
Set of paths that have no copyright information.
-
property is_compliant: bool
Whether the report subset is compliant with the REUSE Spec.
-
class reuse.report.FileReport(name: str, path: str | PathLike[str], do_checksum: bool = True)[source]
Bases: object
Object that holds a linting report about a single file.
-
to_dict_lint() → dict[str, Any][source]
Turn the report into a json-like dictionary with exclusively
information relevant for linting.
-
classmethod generate(project: Project, path: str | PathLike[str], do_checksum: bool = True, add_license_concluded: bool = False) → FileReport[source]
Generate a FileReport from a path in a Project.
-
reuse.report.format_creator(creator: str | None) → str[source]
Render the creator field based on the provided flag