D29: объект путей AppPaths с базой данных из CF_DATA_DIR
infrastructure/cli/paths.py: AppPaths(data_dir, exports_dir) с model_path; from_env() читает CF_DATA_DIR (дефолт ./data — поведение не меняется) на каждую команду. CF_DATA_DIR переопределяет только данные модели: экспорты остаются в ./exports относительно CWD. load_model/save_model, cf init и cf import-xlsx идут через объект; дефолт cf export-xlsx прежний. Тесты: дефолтные пути, переопределение, init/config/info/import/export.
This commit is contained in:
1 parent
f41fc19cc9
commit
6470978693
6 files changed
+153
-17
No files matched your search
@@ -14,7 +14,7 @@ from application.scenarios import ScenarioService
|
||||
from domain import CurrencyConverter, FinancialModel
|
||||
from infrastructure.ai.assistant import AssistantService
|
||||
from infrastructure.cli.i18n import t
|
||||
from infrastructure.cli.paths import MODEL_PATH
|
||||
from infrastructure.cli.paths import AppPaths
|
||||
from infrastructure.repositories import JsonFileRepository
|
||||
|
||||
console = Console()
|
||||
@@ -38,13 +38,14 @@ def fail_validation(exc: ValidationError) -> NoReturn:
|
||||
|
||||
|
||||
def load_model() -> FinancialModel:
|
||||
if MODEL_PATH.exists():
|
||||
return _json_repo.load(MODEL_PATH)
|
||||
model_path = AppPaths.from_env().model_path
|
||||
if model_path.exists():
|
||||
return _json_repo.load(model_path)
|
||||
return FinancialModel()
|
||||
|
||||
|
||||
def save_model(model: FinancialModel) -> None:
|
||||
_json_repo.save(model, MODEL_PATH)
|
||||
_json_repo.save(model, AppPaths.from_env().model_path)
|
||||
|
||||
|
||||
def build_services(
|
||||
|
||||
Reference in new issue
Block a user