Configuration and Settings¶
CalendarApi comes with a lightweight toml config loader and parser for advanced usage.
This module is not yet integrated and exposed as public API
ConfigSection
dataclass
¶
ConfigSection()
Methods:
-
from_config_file–Charge la configuration depuis un fichier toml respectant la structure attendue.
from_config_file
classmethod
¶
from_config_file(
fpath: str | Path, *, with_section: bool = True
) -> ConfigSection
Charge la configuration depuis un fichier toml respectant la structure attendue.
Parameters:
Returns:
-
DatashopConfig(ConfigSection) –Instance configurée selon le fichier renseigné.
Raises:
-
ConfigurationError–Si
strict=Trueet que le fichier de configuration n'existe pas!
Source code in pycalendar_api/config/base.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
ApiConfig
dataclass
¶
ApiConfig(
section: ClassVar = "api",
host: str = "https://calendar-api.ma",
api_endpoint: str = "/api/v1",
api_key: str = "UNDEFINED",
)
API server config section
Methods:
-
from_config_file–Charge la configuration depuis un fichier toml respectant la structure attendue.
from_config_file
classmethod
¶
from_config_file(
fpath: str | Path, *, with_section: bool = True
) -> ConfigSection
Charge la configuration depuis un fichier toml respectant la structure attendue.
Parameters:
Returns:
-
DatashopConfig(ConfigSection) –Instance configurée selon le fichier renseigné.
Raises:
-
ConfigurationError–Si
strict=Trueet que le fichier de configuration n'existe pas!
Source code in pycalendar_api/config/base.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
HTTPClientConfig
dataclass
¶
HTTPClientConfig(
section: ClassVar = "http_client",
default_encoding: str = "utf-8",
timeout: int = 10,
retries: int = 3,
verify: bool = True,
follow_redirects: bool = True,
)
HTTP client config section
Methods:
-
from_config_file–Charge la configuration depuis un fichier toml respectant la structure attendue.
from_config_file
classmethod
¶
from_config_file(
fpath: str | Path, *, with_section: bool = True
) -> ConfigSection
Charge la configuration depuis un fichier toml respectant la structure attendue.
Parameters:
Returns:
-
DatashopConfig(ConfigSection) –Instance configurée selon le fichier renseigné.
Raises:
-
ConfigurationError–Si
strict=Trueet que le fichier de configuration n'existe pas!
Source code in pycalendar_api/config/base.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
Settings
dataclass
¶
Settings(
section: ClassVar = "root",
api: ApiConfig = ApiConfig(),
http_client: HTTPClientConfig = HTTPClientConfig(),
)
pycalendar_api client config file
Methods:
-
__post_init__–One level config File
-
from_config_file–Charge la configuration depuis un fichier toml respectant la structure attendue.
__post_init__
¶
__post_init__()
One level config File
Source code in pycalendar_api/config/settings.py
49 50 51 52 53 54 55 | |
from_config_file
classmethod
¶
from_config_file(
fpath: str | Path, *, with_section: bool = True
) -> ConfigSection
Charge la configuration depuis un fichier toml respectant la structure attendue.
Parameters:
Returns:
-
DatashopConfig(ConfigSection) –Instance configurée selon le fichier renseigné.
Raises:
-
ConfigurationError–Si
strict=Trueet que le fichier de configuration n'existe pas!
Source code in pycalendar_api/config/base.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |