"""Project paths. No absolute paths: everything is resolved from the repository root or from the environment variables VOLVE_DIA_VOLVE_ROOT / VOLVE_DIA_OUTPUTS, which may also be set in `.env`.""" from __future__ import annotations import os from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[1] def load_env(path: Path | None = None) -> None: """Read KEY=VALUE lines of `.env` into os.environ. Variables already set in the environment win.""" path = path or REPO_ROOT / ".env" if not path.is_file(): return for line in path.read_text(encoding="utf-8").splitlines(): line = line.strip() if not line or line.startswith("#") or "=" not in line: continue key, value = line.split("=", 1) os.environ.setdefault(key.strip(), value.strip().strip("'\"")) def volve_root() -> Path: """Volve directory downloaded from the Data Village (Well_technical_data/, WITSML Realtime drilling data/, ...).""" env = os.environ.get("VOLVE_DIA_VOLVE_ROOT") return Path(env) if env else REPO_ROOT / "data" / "Volve" def well_technical_dir() -> Path: return volve_root() / "Well_technical_data" def ddr_xml_dir() -> Path: """1,759 WITSML 1.4 drillReport files: the ground truth of every label.""" return well_technical_dir() / "Daily Drilling Report - XML Version" def ddr_html_dir() -> Path: """The same reports rendered to HTML by the publisher (what the PDF version prints).""" return well_technical_dir() / "Daily Drilling Report - HTML Version" def ddr_pdf_dir() -> Path: return well_technical_dir() / "Daily Drilling report - PDF Version" def witsml_dir() -> Path: return volve_root() / "WITSML Realtime drilling data" def outputs_dir() -> Path: env = os.environ.get("VOLVE_DIA_OUTPUTS") p = Path(env) if env else REPO_ROOT / "outputs" p.mkdir(parents=True, exist_ok=True) return p