2022-10-10 23:46:04 +00:00
|
|
|
from pydantic import BaseModel, BaseSettings
|
|
|
|
|
|
|
|
|
|
|
|
class DavSettings(BaseModel):
|
|
|
|
"""
|
|
|
|
Connection to a DAV server.
|
|
|
|
"""
|
|
|
|
|
|
|
|
protocol: str = "https"
|
|
|
|
host: str = "example.com"
|
|
|
|
username: str = "advent22_user"
|
|
|
|
password: str = "password"
|
|
|
|
path: str = "/remote.php/webdav"
|
|
|
|
prefix: str = "/advent22"
|
|
|
|
|
|
|
|
disable_check: bool = False
|
|
|
|
retries: int = 20
|
|
|
|
|
|
|
|
@property
|
|
|
|
def url(self) -> str:
|
|
|
|
"""
|
|
|
|
Combined DAV URL.
|
|
|
|
"""
|
|
|
|
|
|
|
|
return f"{self.protocol}://{self.host}{self.path}{self.prefix}"
|
2022-10-08 23:36:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Settings(BaseSettings):
|
|
|
|
"""
|
|
|
|
Per-run settings.
|
|
|
|
"""
|
|
|
|
|
|
|
|
#####
|
|
|
|
# general settings
|
|
|
|
#####
|
|
|
|
|
|
|
|
production_mode: bool = False
|
2022-10-27 23:48:02 +00:00
|
|
|
ui_directory: str = "/html"
|
2022-10-08 23:36:16 +00:00
|
|
|
|
|
|
|
#####
|
|
|
|
# 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"
|
|
|
|
|
2022-10-10 23:46:04 +00:00
|
|
|
#####
|
|
|
|
# webdav settings
|
|
|
|
#####
|
|
|
|
|
|
|
|
webdav: DavSettings = DavSettings()
|
|
|
|
|
2022-10-27 23:32:45 +00:00
|
|
|
cache_ttl: int = 30
|
2022-11-04 18:49:31 +00:00
|
|
|
config_filename: str = "config.toml"
|
2022-10-27 23:32:45 +00:00
|
|
|
|
2022-10-10 23:46:04 +00:00
|
|
|
class Config:
|
|
|
|
env_file = ".env"
|
|
|
|
env_file_encoding = "utf-8"
|
|
|
|
env_nested_delimiter = "__"
|
|
|
|
|
2022-10-08 23:36:16 +00:00
|
|
|
|
|
|
|
SETTINGS = Settings()
|