fabricatio_core.decorators

Decorators for Fabricatio.

Functions

cfg_on(→ Callable[[Callable[P, R]], Callable[P, R]])

Synchronous version of the cfg_on decorator.

cfg_on_async(→ Callable[[Callable[P, Coroutine[None, ...)

Asynchronous version of the cfg_on decorator.

depend_on_external_cmd(→ Callable[[Callable[P, R]], ...)

Decorator to check for the presence of an external command.

logging_execution_info(→ Callable[P, R])

Decorator to log the execution of a function.

logging_exec_time(→ Callable[P, R] | Callable[P, ...)

Decorator to log the execution time of a function.

once(…)

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:
  • bin_name (str) – The name of the required binary.

  • install_tip (Optional[str]) – Installation instructions for the required binary.

  • homepage (Optional[str]) – The homepage of the required binary.

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