EOX GitLab Instance

Skip to content
Snippets Groups Projects

Registration routes

Merged Fabian Schindler-Strauss requested to merge routes into main
Files
22
from typing import List
"""Registrar backends.
"""
from ..utils import import_by_path
from .abc import ItemBackend, PathBackend
from .utils import get_backends
def get_backends(config: dict) -> List[ItemBackend]:
"""Gets the backends for registering into
Args:
config (dict): registrar configuration
Returns:
List[ItemBackend]: list of backends where registration will be
carried out
"""
backends: List[ItemBackend] = []
for cfg_backend in config["backends"]:
# construct backend
backend_cls = import_by_path(cfg_backend["path"])
backends.append(
backend_cls(
*cfg_backend.get("args", []),
**cfg_backend.get("kwargs", {}),
)
)
return backends
def get_path_backends(config: dict) -> List[PathBackend]:
"""Gets the backends for registering the path into
Args:
config (dict): registrar configuration
Returns:
List[PathBackend]: list of backends where registration will be
carried out
"""
backends = []
for cfg_backend in config.get("path_backends", []):
# construct backend
backend_cls = import_by_path(cfg_backend["path"])
backends.append(
backend_cls(
*cfg_backend.get("args", []),
**cfg_backend.get("kwargs", {}),
)
)
return backends
__all__ = ["get_backends"]
Loading