2023-01-03 07:54:57 +00:00
|
|
|
from pathlib import Path
|
|
|
|
from typing import Optional
|
2023-12-24 10:43:36 +00:00
|
|
|
from pydantic import AnyHttpUrl, EmailStr, Field
|
|
|
|
from pydantic_settings import BaseSettings
|
2023-01-03 07:54:57 +00:00
|
|
|
|
|
|
|
class Config(BaseSettings):
|
2023-12-24 10:43:36 +00:00
|
|
|
MASTO_URL:str
|
2023-01-03 07:54:57 +00:00
|
|
|
MASTO_TOKEN: Optional[str] = None
|
2023-01-07 07:37:41 +00:00
|
|
|
LOGDIR:Path = Path().home() / '.diyalgo'
|
2023-12-24 10:43:36 +00:00
|
|
|
DB: Optional[Path] = Field(default=Path().home() / '.diyalgo' / 'diyalgo.db')
|
2023-01-07 07:37:41 +00:00
|
|
|
"""
|
|
|
|
Optional, if set to ``None`` , use the in-memory sqlite DB
|
|
|
|
"""
|
|
|
|
|
|
|
|
@property
|
|
|
|
def sqlite_path(self) -> str:
|
|
|
|
if self.DB is None:
|
|
|
|
return 'sqlite://'
|
|
|
|
else:
|
|
|
|
return f'sqlite:///{str(self.DB.resolve())}'
|
2023-01-03 07:54:57 +00:00
|
|
|
|
|
|
|
class Config:
|
|
|
|
env_file = '.env'
|
|
|
|
env_file_encoding = 'utf-8'
|