"""
Provide tools to build core application components.
"""
from contextlib import AsyncExitStack
from types import TracebackType
from typing import Self, Any
from betty.typing import internal, public
[docs]
@internal
class CoreComponent:
"""
A core component.
Core components can manage their resources by being bootstrapped and shut down.
"""
@public
def _assert_bootstrapped(self) -> None:
if not self._bootstrapped:
raise RuntimeError(f"{self} was not bootstrapped yet.")
@public
def _assert_not_yet_bootstrapped(self) -> None:
if self._bootstrapped:
raise RuntimeError(f"{self} was bootstrapped already.")