Spaces:
Sleeping
Sleeping
Download src/retrieval/env_utils.py from Marwan-Tamer/Nura: direct link, hf CLI and curl.
- Browser
- Download file 609 Bytes
-
https://huggingface.co/spaces/Marwan-Tamer/Nura/resolve/09dbec41190d8c10623e478a9a51889efaa3de1d/src/retrieval/env_utils.py
- Command line
-
hf download hf://spaces/Marwan-Tamer/Nura@09dbec41190d8c10623e478a9a51889efaa3de1d/src/retrieval/env_utils.py
-
curl -L -o env_utils.py https://huggingface.co/spaces/Marwan-Tamer/Nura/resolve/09dbec41190d8c10623e478a9a51889efaa3de1d/src/retrieval/env_utils.py
609 Bytes
| from __future__ import annotations | |
| import os | |
| from pathlib import Path | |
| PROJECT_ROOT = Path(__file__).resolve().parents[2] | |
| def load_env_file(path: Path = PROJECT_ROOT / ".env") -> None: | |
| if not path.exists(): | |
| return | |
| for line in path.read_text(encoding="utf-8-sig").splitlines(): | |
| line = line.strip() | |
| if not line or line.startswith("#") or "=" not in line: | |
| continue | |
| key, value = line.split("=", 1) | |
| key = key.strip() | |
| value = value.strip().strip('"').strip("'") | |
| if key and key not in os.environ: | |
| os.environ[key] = value | |