refactor: add paths, services ctx, and extract models to own files

This commit is contained in:
Benjamin Labrecque
2026-07-22 12:04:55 +02:00
parent e324e3abed
commit 7e690a907e
16 changed files with 474 additions and 524 deletions
+19 -12
View File
@@ -1,14 +1,13 @@
from pathlib import Path
from pydantic import DirectoryPath, FilePath
from pydantic_settings import BaseSettings
from pydantic import BaseModel, DirectoryPath, FilePath
from core.utils import get_git_root
REPO_ROOT = get_git_root(__file__)
class Paths(BaseSettings):
class Paths(BaseModel):
# fmt: off
repo_root: DirectoryPath = REPO_ROOT
@@ -19,17 +18,25 @@ class Paths(BaseSettings):
service_manager_ui_file: FilePath = repo_root / "qt" / "A_BD_ServiceManager.ui"
# fmt: on
def get_files_to_stage(self, service_dir_name: str) -> list[str]:
"""
Returns all required relative file paths for git staging.
"""
service_current = self.repo_root / "services" / service_dir_name / "current"
staged_paths = [
service_current,
self.service_registry_file,
self.master_hla_names_file,
self.master_ioc_subs_file,
self.iocs_overview_filename,
self.service_manager_ui_file,
]
return [self.relative(p) for p in staged_paths]
def relative(self, path: Path) -> str:
"""
Convert any absolute path into a string path relative to repo_root.
"""
return str(path.relative_to(self.repo_root))
def get_service_dir(self, service_dir_name: str) -> Path:
"""
Helper to get a service path dynamically.
"""
return self.repo_root / "services" / service_dir_name / "current"
paths = Paths()