33 lines
579 B
Python
33 lines
579 B
Python
from typing import TypeVar
|
|
|
|
from .source import ApiSource
|
|
|
|
S = TypeVar("S", bound=ApiSource)
|
|
|
|
|
|
class Api[S = ApiSource]:
|
|
TYPE: str
|
|
PROVIDER: str
|
|
|
|
_source: S | None = None
|
|
|
|
def _build_source(self) -> S:
|
|
raise NotImplementedError
|
|
|
|
@property
|
|
def type(self) -> str:
|
|
return self.TYPE
|
|
|
|
@property
|
|
def provider(self) -> str:
|
|
return self.PROVIDER
|
|
|
|
@property
|
|
def source(self) -> S:
|
|
if self._source is None:
|
|
self._source = self._build_source()
|
|
return self._source
|
|
|
|
|
|
API = TypeVar("API", bound=Api)
|