Skip to content

verify.common

What the subcommands of verify share: the output and the project.

UsageError

Bases: Exception

A subcommand cannot run as it was asked to, exit code 2.

ProjectNotLoaded

Bases: UsageError

The project cannot be loaded, exit code 4 as for the kinds of the run layer.

report

report(text='')

Write a line of the result of a subcommand to stdout.

Unlike a log record it is the output of the command, written as it is (no wrapping, markup, emoji or tab expansion), so that it can be redirected and compared.

add_project_arguments

add_project_arguments(parser, required=True)

Add --project and --root to the parser of a subcommand.

outside_root

outside_root(project, root)

Check that the module of a project was imported from below root.

--root is put first on the python path, but a package which is already imported (a second call in the same process) or installed in an environment in which the root does not take effect would silently be dumped from somewhere else.

Parameters:

Name Type Description Default
project str

the reference module:attribute of the project.

required
root Path

the directory the module must be imported from.

required

Returns:

Type Description
str | None

A message if the module comes from elsewhere, else None.

load_project_of

load_project_of(args)

Load the project of the arguments, --project below --root.

Parameters:

Name Type Description Default
args Namespace

the parsed arguments with project and root.

required

Returns:

Type Description
Project

The project.

Raises:

Type Description
ProjectNotLoaded

if the project cannot be loaded or is imported from outside of --root.