Coverage for pydaconf/plugins/base.py: 100.00%
14 statements
« prev ^ index » next coverage.py v7.6.11, created at 2025-02-16 17:46 +0000
« prev ^ index » next coverage.py v7.6.11, created at 2025-02-16 17:46 +0000
1from abc import ABC, abstractmethod
2from collections.abc import Callable
4from pydaconf.utils.exceptions import PluginException
7class PluginBase(ABC):
8 """Abstract Base Class for plugins."""
10 def _execute_plugin(self, value: str, on_update_callback: Callable[[str], None]) -> str:
11 """This method is intended to be called only from PyDaConf provider"""
12 try:
13 return self.run(value, on_update_callback)
14 except Exception as e:
15 raise PluginException(
16 f"Plugin '{self.__class__.__name__}' failed to get data for value '{value}'. Error: {str(e)}") from e
18 @property
19 @abstractmethod
20 def PREFIX(self) -> str:
21 raise NotImplementedError
24 @abstractmethod
25 def run(self, value: str, on_update_callback: Callable[[str], None]) -> str:
26 raise NotImplementedError