reuse.global_licensing module¶
Code for parsing and validating REUSE.toml.
- reuse.global_licensing.REUSE_TOML_VERSION = 1¶
Current version of REUSE.toml.
- class reuse.global_licensing.PrecedenceType(value)[source]¶
Bases:
EnumAn enum of behaviours surrounding order of precedence for entries in a
GlobalLicensing.- AGGREGATE = 'aggregate'¶
Aggregate the results from the file with the results from the global licensing file.
- CLOSEST = 'closest'¶
Use the results that are closest to the covered file. This is typically the file itself, or the global licensing file if no REUSE information exists inside of the file.
- OVERRIDE = 'override'¶
Only use the results from the global licensing file.
- class reuse.global_licensing.GlobalLicensing(source: str)[source]¶
Bases:
ABCAn abstract class that represents a configuration file that contains licensing information that is pertinent to other files in the project.
- abstract classmethod from_file(path: str | PathLike[str], **kwargs: Any) GlobalLicensing[source]¶
Parse the file and create a
GlobalLicensingobject from its contents.- Raises:
FileNotFoundError – file doesn’t exist.
OSError – some other error surrounding I/O.
GlobalLicensingParseError – file could not be parsed.
- abstract reuse_info_of(path: str | PathLike[str]) dict[PrecedenceType, list[ReuseInfo]][source]¶
Find the REUSE information of path defined in the configuration. The path must be relative to the root of a
reuse.project.Project.The key indicates the precedence type for the subsequent information.
- class reuse.global_licensing.ReuseDep5(source: str, dep5_copyright: Copyright)[source]¶
Bases:
GlobalLicensingA soft wrapper around
Copyright.- dep5_copyright: Copyright¶
- classmethod from_file(path: str | PathLike[str], **kwargs: Any) ReuseDep5[source]¶
Parse the file and create a
GlobalLicensingobject from its contents.- Raises:
FileNotFoundError – file doesn’t exist.
OSError – some other error surrounding I/O.
GlobalLicensingParseError – file could not be parsed.
- reuse_info_of(path: str | PathLike[str]) dict[PrecedenceType, list[ReuseInfo]][source]¶
Find the REUSE information of path defined in the configuration. The path must be relative to the root of a
reuse.project.Project.The key indicates the precedence type for the subsequent information.
- class reuse.global_licensing.AnnotationsItem(paths: Any | None, precedence: Any = PrecedenceType.CLOSEST, copyright_notices: Any | None = None, spdx_expressions: Any | None = None)[source]¶
Bases:
objectA class that maps to a single [[annotations]] table element in REUSE.toml.
- precedence: PrecedenceType¶
- copyright_notices: set[CopyrightNotice]¶
- spdx_expressions: set[SpdxExpression]¶
- classmethod from_dict(values: dict[str, Any]) AnnotationsItem[source]¶
Create an
AnnotationsItemfrom a dictionary that uses the key-value pairs for an [[annotations]] table in REUSE.toml.
- matches(path: str) bool[source]¶
Determine whether path matches any of the paths (or path globs) in
AnnotationsItem.
- class reuse.global_licensing.ReuseTOML(source: str, version: int, annotations: list[AnnotationsItem])[source]¶
Bases:
GlobalLicensingA class that contains the data parsed from a REUSE.toml file.
- annotations: list[AnnotationsItem]¶
- classmethod from_dict(values: dict[str, Any], source: str) ReuseTOML[source]¶
Create a
ReuseTOMLfrom the dict version of REUSE.toml.
- classmethod from_file(path: str | PathLike[str], **kwargs: Any) ReuseTOML[source]¶
Parse the file and create a
GlobalLicensingobject from its contents.- Raises:
FileNotFoundError – file doesn’t exist.
OSError – some other error surrounding I/O.
GlobalLicensingParseError – file could not be parsed.
- find_annotations_item(path: str | PathLike[str]) AnnotationsItem | None[source]¶
Find a
AnnotationsItemthat matches path. The latest match inannotationsis returned.
- reuse_info_of(path: str | PathLike[str]) dict[PrecedenceType, list[ReuseInfo]][source]¶
Find the REUSE information of path defined in the configuration. The path must be relative to the root of a
reuse.project.Project.The key indicates the precedence type for the subsequent information.
- class reuse.global_licensing.NestedReuseTOML(source: str, reuse_tomls: list[ReuseTOML])[source]¶
Bases:
GlobalLicensingA class that represents a hierarchy of
ReuseTOMLobjects.- classmethod from_file(path: str | PathLike[str], **kwargs: Any) NestedReuseTOML[source]¶
TODO: path is a directory instead of a file.
- reuse_info_of(path: str | PathLike[str]) dict[PrecedenceType, list[ReuseInfo]][source]¶
Find the REUSE information of path defined in the configuration. The path must be relative to the root of a
reuse.project.Project.The key indicates the precedence type for the subsequent information.
- classmethod find_reuse_tomls(path: str | PathLike[str], include_submodules: bool = False, include_meson_subprojects: bool = False, vcs_strategy: VCSStrategy | None = None) Generator[Path, None, None][source]¶
Find all REUSE.toml files in path. path should be the root of the directory. If it is not, REUSE.toml files which are in ignored directories may not be correctly ignored.