niquery.utils.decorators module

niquery.utils.decorators.require_datalad(func: F) F[source]

Decorator for functions that require DataLad.

Checks whether DataLad and its required dependencies are available in the environment: if DataLad or its required system dependencies are not available, calling the decorated function will raise a RuntimeError with an informative message.

Parameters:

func (Callable) – The function to be decorated. This function should depend on DataLad being installed and the git and git-annex system tools being available.

Returns:

The wrapped function, which will only execute if DataLad is available.

Return type:

Callable

Raises:

RuntimeError – If DataLad or its dependencies are not available when the decorated function is called.

Examples

@require_datalad
def my_function(...):
    ...

See also

have_datalad

niquery.utils.decorators.require_datalad_click(func: F) F[source]

Decorator for click command functions that require DataLad.

If DataLad or its required system dependencies are not available, calling the decorated function will raise a RuntimeError with an informative message.

Checks whether DataLad and its required dependencies are available in the environment: if DataLad or its required system dependencies are not available, it raises a ClickException with a descriptive error message.

Returns:

The wrapped click command function, which will only execute if DataLad is available.

Return type:

Callable

Raises:

ClickException – If DataLad or its dependencies are not available.

Examples

@click.command()
@require_datalad_click
def my_command():
    ...

See also

require_datalad