small updates
This commit is contained in:
1 parent
25632e1938
commit
965af7e4ee
5 files changed
+57
-16
No files matched your search
+18
-6
@@ -1,6 +1,8 @@
|
||||
import json
|
||||
from enum import Enum
|
||||
from functools import cache
|
||||
import pathlib
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
|
||||
from monitor_utils.constants import PROXIES_PATH, PROJECT_ROOT
|
||||
@@ -22,6 +24,13 @@ class Settings(BaseSettings):
|
||||
|
||||
model_config = SettingsConfigDict(env_file=(".env", ".env.local"), extra="ignore")
|
||||
|
||||
@property
|
||||
def bot_token(self) -> str:
|
||||
if self.development_mode == DevelopmentMode.PRODUCTION:
|
||||
return self.production_bot_token
|
||||
|
||||
return self.development_bot_token
|
||||
|
||||
|
||||
@cache
|
||||
def get_settings() -> Settings:
|
||||
@@ -39,11 +48,14 @@ def get_proxies() -> list[str]:
|
||||
return proxies
|
||||
|
||||
|
||||
def get_config(config_name: str, use_production_path: bool = False) -> dict:
|
||||
config_name = config_name.replace(".json", "")
|
||||
def get_config(
|
||||
monitor_name: str, use_production_path: bool = False
|
||||
) -> tuple[dict, pathlib.Path]:
|
||||
monitor_name = monitor_name.replace(".json", "")
|
||||
if use_production_path:
|
||||
config_path = PROJECT_ROOT / "configs" / f"{config_name}.json"
|
||||
config_path = PROJECT_ROOT / "configs" / f"{monitor_name}.json"
|
||||
else:
|
||||
config_path = PROJECT_ROOT / "tests" / "configs" / f"{config_name}.json"
|
||||
with open(config_path) as config:
|
||||
return json.load(config)
|
||||
config_path = PROJECT_ROOT / "tests" / "configs" / f"{monitor_name}.json"
|
||||
|
||||
with open(config_path) as f:
|
||||
return json.load(f), config_path
|
||||
Reference in new issue
Block a user