reuse package#


Module contents#

reuse is a tool for compliance with the REUSE recommendations.

Although the API is documented, it is NOT guaranteed stable between minor or even patch releases. The semantic versioning of this program pertains exclusively to the reuse CLI command. If you want to use reuse as a Python library, you should pin reuse to an exact version.

Having given the above disclaimer, the API has been relatively stable nevertheless, and we (the maintainers) do make some efforts to not needlessly change the public API.

exception reuse.IdentifierNotFound[source]#

Bases: ReuseException

Could not find SPDX identifier for license file.

exception reuse.ReuseException[source]#

Bases: Exception

Base exception.

class reuse.ReuseInfo(spdx_expressions: ~typing.Set[~boolean.boolean.Expression] = <factory>, copyright_lines: ~typing.Set[str] = <factory>, contributor_lines: ~typing.Set[str] = <factory>, path: str | None = None, source_path: str | None = None, source_type: ~reuse.SourceType | None = None)[source]#

Bases: object

Simple dataclass holding licensing and copyright information

Either spdx_expressions or copyright_lines is non-empty.

contains_info() bool[source]#

Any field except path, source_path and source_type is non-empty.

contributor_lines: Set[str]#
copy(**kwargs: Any) ReuseInfo[source]#

Return a copy of ReuseInfo, replacing the values of attributes with the values from kwargs.

copyright_lines: Set[str]#
path: str | None = None#
source_path: str | None = None#
source_type: SourceType | None = None#
spdx_expressions: Set[Expression]#
union(value: ReuseInfo) ReuseInfo[source]#

Return a new instance of ReuseInfo where all Set attributes are equal to the union of the set in self and the set in value.

All non-Set attributes are set to their values in self.

>>> one = ReuseInfo(copyright_lines={"Jane Doe"}, source_path="")
>>> two = ReuseInfo(copyright_lines={"John Doe"}, source_path="")
>>> result = one.union(two)
>>> print(sorted(result.copyright_lines))
['Jane Doe', 'John Doe']
>>> print(result.source_path)
class reuse.SourceType(value)[source]#

Bases: Enum

An enumeration representing the types of sources for license information.

DEP5 = 'dep5'#

A .reuse/dep5 file containing license information.

DOT_LICENSE = 'dot-license'#

A .license file containing license information.

FILE_HEADER = 'file-header'#

A file header containing license information.