Skip to content

bootstrap

dev_tool.launcher.bootstrap

F = TypeVar('F', bound=(Callable[..., Any])) module-attribute

log = logging.getLogger(__name__) module-attribute

bootstrap

A decorator that ensures the basic configuration files exist before executing a function.

This decorator creates default configuration files if they don't exist.

Parameters:

  • func (F) –

    The function to decorate.

Returns:

  • F

    The decorated function.

Source code in dev_tool/launcher/bootstrap.py
def bootstrap(func: F) -> F:
    """
    A decorator that ensures the basic configuration files exist before executing a function.

    This decorator creates default configuration files if they don't exist.

    :param func: The function to decorate.
    :return: The decorated function.
    """

    @wraps(func)
    def wrapper(*args, **kwargs) -> Any:
        if not PYPROJECT.exists():
            CONTEXT.configuration.create_default_pyproject()

        if not DEVELOPMENT_ENV.exists():
            CONTEXT.configuration.create_default_development_env()

        return func(*args, **kwargs)

    return cast('F', wrapper)