reuse.vcs module#

This module deals with version control systems.

class reuse.vcs.VCSStrategy(project: Project)[source]#

Bases: ABC

Strategy pattern for version control systems.

EXE: str | None = None#
abstract classmethod find_root(cwd: str | PathLike | None = None) Path | None[source]#

Try to find the root of the project from cwd. If none is found, return None.

Raises:

NotADirectoryError – if directory is not a directory.

abstract classmethod in_repo(directory: str | PathLike) bool[source]#

Is directory inside of the VCS repository?

Raises:

NotADirectoryError – if directory is not a directory.

abstract is_ignored(path: str | PathLike) bool[source]#

Is path ignored by the VCS?

abstract is_submodule(path: str | PathLike) bool[source]#

Is path a VCS submodule?

class reuse.vcs.VCSStrategyGit(project: Project)[source]#

Bases: VCSStrategy

Strategy that is used for Git.

EXE: str | None = '/usr/bin/git'#
classmethod find_root(cwd: str | PathLike | None = None) Path | None[source]#

Try to find the root of the project from cwd. If none is found, return None.

Raises:

NotADirectoryError – if directory is not a directory.

classmethod in_repo(directory: str | PathLike) bool[source]#

Is directory inside of the VCS repository?

Raises:

NotADirectoryError – if directory is not a directory.

is_ignored(path: str | PathLike) bool[source]#

Is path ignored by the VCS?

is_submodule(path: str | PathLike) bool[source]#

Is path a VCS submodule?

class reuse.vcs.VCSStrategyHg(project: Project)[source]#

Bases: VCSStrategy

Strategy that is used for Mercurial.

EXE: str | None = '/usr/bin/hg'#
classmethod find_root(cwd: str | PathLike | None = None) Path | None[source]#

Try to find the root of the project from cwd. If none is found, return None.

Raises:

NotADirectoryError – if directory is not a directory.

classmethod in_repo(directory: str | PathLike) bool[source]#

Is directory inside of the VCS repository?

Raises:

NotADirectoryError – if directory is not a directory.

is_ignored(path: str | PathLike) bool[source]#

Is path ignored by the VCS?

is_submodule(path: str | PathLike) bool[source]#

Is path a VCS submodule?

class reuse.vcs.VCSStrategyNone(project: Project)[source]#

Bases: VCSStrategy

Strategy that is used when there is no VCS.

classmethod find_root(cwd: str | PathLike | None = None) Path | None[source]#

Try to find the root of the project from cwd. If none is found, return None.

Raises:

NotADirectoryError – if directory is not a directory.

classmethod in_repo(directory: str | PathLike) bool[source]#

Is directory inside of the VCS repository?

Raises:

NotADirectoryError – if directory is not a directory.

is_ignored(path: str | PathLike) bool[source]#

Is path ignored by the VCS?

is_submodule(path: str | PathLike) bool[source]#

Is path a VCS submodule?

class reuse.vcs.VCSStrategyPijul(project: Project)[source]#

Bases: VCSStrategy

Strategy that is used for Pijul.

EXE: str | None = None#
classmethod find_root(cwd: str | PathLike | None = None) Path | None[source]#

Try to find the root of the project from cwd. If none is found, return None.

Raises:

NotADirectoryError – if directory is not a directory.

classmethod in_repo(directory: str | PathLike) bool[source]#

Is directory inside of the VCS repository?

Raises:

NotADirectoryError – if directory is not a directory.

is_ignored(path: str | PathLike) bool[source]#

Is path ignored by the VCS?

is_submodule(path: str | PathLike) bool[source]#

Is path a VCS submodule?

reuse.vcs.all_vcs_strategies() Generator[Type[VCSStrategy], None, None][source]#

Yield all VCSStrategy classes that aren’t the abstract base class.

reuse.vcs.find_root(cwd: str | PathLike | None = None) Path | None[source]#

Try to find the root of the project from cwd. If none is found, return None.

Raises:

NotADirectoryError – if directory is not a directory.