reuse.project module

Module that contains the central Project class.

class reuse.project.Project(root: os.PathLike, include_submodules: bool = False, include_meson_subprojects: bool = False)[source]

Bases: object

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

all_files(directory: Optional[os.PathLike] = None) Iterator[pathlib.Path][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.

relative_from_root(path: pathlib.Path) pathlib.Path[source]

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

property root: pathlib.Path

Path to the root of the project.

spdx_info_of(path: os.PathLike) reuse.SpdxInfo[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.

reuse.project.create_project() reuse.project.Project[source]

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