mt5-manager/config.py
Yuriy Bykov Yuriy Bykov dbed2c48f9 Edit article part 4, add testing section and screenshots
Article:
- edit all sections, shorten schema drift story,
  drop the useful-links and warning sections, keep first-level TOC only
- add "Тестирование" with three 750 px screenshots (docs/images)
- add "Содержание архива" with file versions

Code:
- ServiceStateWriter.mq5: use TERMINAL_DATA_PATH (portable-only), replace
  ExecutePragma() with DatabaseExecute(), use built-in
  ERR_DATABASE_NO_MORE_DATA, align comments with the article
- deploy_service.py: skip compilation when .ex5 is newer than the source
- bump versions: main.py 0.3.0, config.py 0.2.0, static/script.js 0.2.0

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 21:19:21 +03:00
44 lines
1.3 KiB
Python
'''
File: config.py
Description: Класс работы с конфигурацией приложения
'''
__version__ = '0.2.0'
from pydantic_settings import BaseSettings, JsonConfigSettingsSource, SettingsConfigDict
import os
class Config(BaseSettings):
# Словарь с информацией о терминалах
terminals: dict
# Путь к папке с экземплярами терминалов
mt5_folder: str
# Имя исполняемого файла терминала
mt5_exe: str
# Путь к общей базе SQLite (папка Common/Files, зависит от профиля Windows)
database: str
model_config = SettingsConfigDict()
@classmethod
def settings_customise_sources(
cls,
settings_cls,
init_settings,
env_settings,
dotenv_settings,
file_secret_settings,
):
# Получаем путь к файлу из переменной окружения
config_file = os.getenv("MT5_MANAGER_CONFIG_FILE", "config.json")
return (
init_settings,
JsonConfigSettingsSource(settings_cls, json_file=config_file),
env_settings,
dotenv_settings,
file_secret_settings,
)