fabricatio_core.decorators
Decorators for Fabricatio.
Functions
|
Synchronous version of the cfg_on decorator. |
|
Asynchronous version of the cfg_on decorator. |
|
Decorator to check for the presence of an external command. |
|
Decorator to log the execution of a function. |
|
Decorator to log the execution time of a function. |
|
Decorator to ensure a function is called only once. |
Module Contents
- fabricatio_core.decorators.cfg_on[**P, R](feats: Sequence[str]) Callable[[Callable[P, R]], Callable[P, R]][source]
Synchronous version of the cfg_on decorator.
Ensures configuration is applied before executing a synchronous function.
- Parameters:
feats (Sequence[str]) – Required feature names (e.g., [“workflow”, “debug”]).
- Returns:
Decorator for synchronous functions.
- Return type:
Callable
- fabricatio_core.decorators.cfg_on_async[**P, R](feats: Sequence[str]) Callable[[Callable[P, Coroutine[None, None, R]]], Callable[P, Coroutine[None, None, R]]][source]
Asynchronous version of the cfg_on decorator.
Ensures configuration is applied before executing an asynchronous function.
- Parameters:
feats (Sequence[str]) – Required feature names (e.g., [“workflow”, “debug”]).
- Returns:
Decorator for asynchronous functions.
- Return type:
Callable
- fabricatio_core.decorators.depend_on_external_cmd[**P, R](bin_name: str, install_tip: str | None, homepage: str | None = None) Callable[[Callable[P, R]], Callable[P, R]][source]
Decorator to check for the presence of an external command.
- Parameters:
- Returns:
A decorator that wraps the function to check for the binary.
- Return type:
Callable[[Callable[P, R]], Callable[P, R]]
- Raises:
RuntimeError – If the required binary is not found.
- fabricatio_core.decorators.logging_execution_info[**P, R](func: Callable[P, R]) Callable[P, R][source]
Decorator to log the execution of a function.
- Parameters:
func (Callable) – The function to be executed
- Returns:
A decorator that wraps the function to log the execution.
- Return type:
Callable
- fabricatio_core.decorators.logging_exec_time[**P, R](func: Callable[P, R] | Callable[P, Coroutine[None, None, R]]) Callable[P, R] | Callable[P, Coroutine[None, None, R]][source]
Decorator to log the execution time of a function.
- Parameters:
func (Callable) – The function to be executed
- Returns:
A decorator that wraps the function to log the execution time.
- Return type:
Callable
- fabricatio_core.decorators.once[**P, R](func: Callable[P, Coroutine[None, None, R]]) Callable[P, Coroutine[None, None, R]][source]
- fabricatio_core.decorators.once(func: Callable[P, R]) Callable[P, R]
Decorator to ensure a function is called only once.
Subsequent calls will return the cached result from the first call.
- Parameters:
func (Callable) – The function to be executed only once
- Returns:
A decorator that wraps the function to execute it only once
- Return type:
Callable