reuse.project module

Module that contains the central Project class.

class reuse.project.Project(root, include_submodules=False)[source]

Bases: object

Simple object that holds the project’s root, which is necessary for many interactions.

all_files(directory=None)[source]

Yield all files in directory and its subdirectories.

The files that are not yielded are:

  • Files ignored by VCS (e.g., see .gitignore)

  • Files/directories matching IGNORE_*_PATTERNS.

Return type

Iterator[Path]

relative_from_root(path)[source]

If the project root is /tmp/project, and path is /tmp/project/src/file, then return src/file.

Return type

Path

property root

Path to the root of the project.

Return type

Path

spdx_info_of(path)[source]

Return SPDX info of path.

This function will return any SPDX information that it can find, both from within the file and from the .reuse/dep5 file.

Return type

SpdxInfo

reuse.project.create_project()[source]

Create a project object. Try to find the project root from CWD, otherwise treat CWD as root.

Return type

Project