reuse.project module#

Module that contains the central Project class.

class reuse.project.Project(root, include_submodules=False, include_meson_subprojects=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: :rtype: Iterator[Path]

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

  • Files/directories matching IGNORE_*_PATTERNS.

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

reuse_info_of(path)[source]#

Return REUSE info of path.

This function will return any REUSE information that it can find: from within the file, the .license file and/or from the .reuse/dep5 file.

The presence of a .license file always means that the file itself will not be parsed for REUSE information.

When the .reuse/dep5 file covers a file and there is also REUSE information within that file (or within its .license file), then two ReuseInfo objects are returned in the set, each with respective discovered REUSE information and information about the source.

Return type:

List[ReuseInfo]

property root: Path#

Path to the root of the project.

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