| 1893 | |
| 1894 | |
| 1895 | def _load_local_env_file(): |
| 1896 | env_path = Path(__file__).resolve().parent / ".env" |
| 1897 | if not env_path.exists(): |
| 1898 | return |
| 1899 | try: |
| 1900 | for raw_line in env_path.read_text(encoding="utf-8").splitlines(): |
| 1901 | line = raw_line.strip() |
| 1902 | if not line or line.startswith("#") or "=" not in line: |
| 1903 | continue |
| 1904 | key, value = line.split("=", 1) |
| 1905 | key = key.strip() |
| 1906 | value = value.strip().strip('"').strip("'") |
| 1907 | if key and key not in os.environ: |
| 1908 | os.environ[key] = value |
| 1909 | except Exception: |
| 1910 | print("[!] File .env presente ma non leggibile. Verifica permessi e formato.") |
| 1911 | |
| 1912 | |
| 1913 | def _read_env_file_values(env_path: Path) -> dict: |