reuse package

Submodules

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.

class reuse.SourceType(value)[source]

Bases: Enum

An enumeration representing the types of sources for license information.

DOT_LICENSE = 'dot-license'

A .license file containing license information.

FILE_HEADER = 'file-header'

A file header containing license information.

DEP5 = 'dep5'

A .reuse/dep5 file containing license information.

REUSE_TOML = 'reuse-toml'

A REUSE.toml file containing license information.

class reuse.ReuseInfo(spdx_expressions: set[~boolean.boolean.Expression] = <factory>, copyright_lines: set[str] = <factory>, contributor_lines: 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

spdx_expressions: set[Expression]
copyright_lines: set[str]
contributor_lines: set[str]
path: str | None = None
source_path: str | None = None
source_type: SourceType | None = None
copy(**kwargs: Any) ReuseInfo[source]

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

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="foo.py")
>>> two = ReuseInfo(copyright_lines={"John Doe"}, source_path="bar.py")
>>> result = one.union(two)
>>> print(sorted(result.copyright_lines))
['Jane Doe', 'John Doe']
>>> print(result.source_path)
foo.py

Either spdx_expressions or copyright_lines is non-empty.

One of spdx_expressions or copyright_lines is non-empty.

contains_info() bool[source]

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