Source code for betty.load

"""
Provide the Ancestry loading API.
"""

import logging

from betty.app import App
from betty.warnings import deprecated


[docs] @deprecated( "This function is deprecated as of Betty 0.3.2, and will be removed in Betty 0.4.x. Instead, use `logging.getLogger()`." ) def getLogger() -> logging.Logger: """ Get the ancestry loading logger. """ return logging.getLogger(__name__)
[docs] class Loader: """ Load (part of) the project's ancestry. Extensions may subclass this to add data to the ancestry, if they choose to do so. """
[docs] async def load(self) -> None: """ Load ancestry data. """ raise NotImplementedError(repr(self))
[docs] class PostLoader: """ Act on the project's ancestry having been loaded. """
[docs] async def post_load(self) -> None: """ Act on the ancestry having been loaded. This method is called immediately after :py:meth:`betty.load.Loader.load`. """ raise NotImplementedError(repr(self))
[docs] async def load(app: App) -> None: """ Load an ancestry. """ await app.dispatcher.dispatch(Loader)() await app.dispatcher.dispatch(PostLoader)()