| 12345678910111213141516171819202122232425 |
- import logging
- import sys
- from typing import NoReturn
- import tomli
- from app.schema import Settings
- logger = logging.getLogger(__name__)
- def read_settings(filepath: str) -> Settings | NoReturn:
- """Read settings.toml from the root of the project folder"""
- try:
- with open(filepath, mode="rb") as f:
- config = tomli.load(f)
- settings = Settings(**config)
- return settings
- except FileNotFoundError:
- logger.error(
- f"error => {filepath} has not been found\n",
- " please check the README for instructions",
- )
- sys.exit(1)
|