mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-12-26 22:23:02 +00:00
63 lines
1.2 KiB
Python
63 lines
1.2 KiB
Python
from pydantic import BaseModel
|
|
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
|
|
|
|
class DavSettings(BaseModel):
|
|
"""
|
|
Connection to a DAV server.
|
|
"""
|
|
|
|
protocol: str = "https"
|
|
host: str = "example.com"
|
|
path: str = "/remote.php/webdav"
|
|
prefix: str = "/advent22"
|
|
|
|
username: str = "advent22_user"
|
|
password: str = "password"
|
|
|
|
cache_ttl: int = 60 * 30
|
|
config_filename: str = "config.toml"
|
|
|
|
@property
|
|
def url(self) -> str:
|
|
"""
|
|
Combined DAV URL.
|
|
"""
|
|
|
|
return f"{self.protocol}://{self.host}{self.path}{self.prefix}"
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
"""
|
|
Per-run settings.
|
|
"""
|
|
|
|
model_config = SettingsConfigDict(
|
|
env_file=".env",
|
|
env_file_encoding="utf-8",
|
|
env_nested_delimiter="__",
|
|
)
|
|
|
|
#####
|
|
# general settings
|
|
#####
|
|
|
|
production_mode: bool = False
|
|
ui_directory: str = "/html"
|
|
|
|
#####
|
|
# openapi settings
|
|
#####
|
|
|
|
openapi_url: str = "/openapi.json"
|
|
docs_url: str | None = None if production_mode else "/docs"
|
|
redoc_url: str | None = None if production_mode else "/redoc"
|
|
|
|
#####
|
|
# webdav settings
|
|
#####
|
|
|
|
webdav: DavSettings = DavSettings()
|
|
|
|
|
|
SETTINGS = Settings()
|