Source code for pyobs.interfaces.IConfig

from __future__ import annotations

from abc import ABCMeta, abstractmethod
from dataclasses import dataclass, field
from typing import Any

from .interface import Interface

ConfigScalar = bool | int | float | str
ConfigValue = ConfigScalar | list[ConfigScalar] | dict[str, ConfigScalar]


[docs] @dataclass class ConfigCapabilities: caps: dict[str, tuple[bool, bool, bool]] = field(default_factory=dict)
class IConfig(Interface, metaclass=ABCMeta): """The module allows access to some of its configuration options.""" __module__ = "pyobs.interfaces" capabilities = ConfigCapabilities
[docs] @abstractmethod async def get_config_value(self, name: str, **kwargs: Any) -> ConfigValue: """Returns current value of config item with given name. Args: name: Name of config item. Returns: Current value. Raises: InvalidArgumentError: If config item of given name does not exist. """ ...
[docs] @abstractmethod async def set_config_value(self, name: str, value: ConfigValue, **kwargs: Any) -> None: """Sets value of config item with given name. Args: name: Name of config item. value: New value. Raises: InvalidArgumentError: If config item of given name does not exist. ValueError: If value is invalid. """ ...
__all__ = ["IConfig", "ConfigCapabilities", "ConfigScalar", "ConfigValue"]