improve typing for config
This commit is contained in:
parent
a020d972f8
commit
c9c95ba2fa
1 changed files with 12 additions and 12 deletions
|
|
@ -2,20 +2,20 @@ import os
|
|||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
datadir = Path(os.getenv("UNWIND_DATA") or "./data")
|
||||
cachedir = (
|
||||
Path(cachedir)
|
||||
if (cachedir := os.getenv("UNWIND_CACHEDIR", datadir / ".cache"))
|
||||
else None
|
||||
datadir: Path = Path(os.getenv("UNWIND_DATA") or "./data")
|
||||
cachedir: Path = Path(p) if (p := os.getenv("UNWIND_CACHEDIR")) else datadir / ".cache"
|
||||
debug: bool = os.getenv("DEBUG") == "1"
|
||||
loglevel: str = os.getenv("UNWIND_LOGLEVEL") or ("DEBUG" if debug else "INFO")
|
||||
storage_path: Path = (
|
||||
Path(p) if (p := os.getenv("UNWIND_STORAGE")) else datadir / "db.sqlite"
|
||||
)
|
||||
config_path: Path = (
|
||||
Path(p) if (p := os.getenv("UNWIND_CONFIG")) else datadir / "config.toml"
|
||||
)
|
||||
debug = os.getenv("DEBUG") == "1"
|
||||
loglevel = os.getenv("UNWIND_LOGLEVEL") or ("DEBUG" if debug else "INFO")
|
||||
storage_path = os.getenv("UNWIND_STORAGE", datadir / "db.sqlite")
|
||||
config_path = os.getenv("UNWIND_CONFIG", datadir / "config.toml")
|
||||
|
||||
with open(config_path, "rb") as fd:
|
||||
_config = tomllib.load(fd)
|
||||
|
||||
api_base = _config["api"].get("base", "/api/")
|
||||
api_cors = _config["api"].get("cors", "*")
|
||||
api_credentials = _config["api"].get("credentials", {})
|
||||
api_base: str = _config["api"].get("base", "/api/")
|
||||
api_cors: str = _config["api"].get("cors", "*")
|
||||
api_credentials: dict[str, str] = _config["api"].get("credentials", {})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue