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
RuntimeErrorwith an informative message.- Parameters:
func (
Callable) – The function to be decorated. This function should depend on DataLad being installed and thegitandgit-annexsystem 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.
Usage –
----- –
@require_datalad –
def my_function(...): –
…
See also
- 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
RuntimeErrorwith 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
clickClickExceptionwith a descriptive error message.- Returns:
The wrapped
clickcommand function, which will only execute if DataLad is available.- Return type:
Callable- Raises:
clickClickException – If DataLad or its dependencies are not available.
Usage –
----- –
@click.command() –
@require_datalad_click –
def my_command(): –
…
See also