24 lines
695 B
Python
24 lines
695 B
Python
from pathlib import Path
|
|
from typing import Optional
|
|
from pydantic import AnyHttpUrl, EmailStr, Field
|
|
from pydantic_settings import BaseSettings
|
|
|
|
class Config(BaseSettings):
|
|
MASTO_URL:str
|
|
MASTO_TOKEN: Optional[str] = None
|
|
LOGDIR:Path = Path().home() / '.diyalgo'
|
|
DB: Optional[Path] = Field(default=Path().home() / '.diyalgo' / 'diyalgo.db')
|
|
"""
|
|
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())}'
|
|
|
|
class Config:
|
|
env_file = '.env'
|
|
env_file_encoding = 'utf-8' |