claude-proxy / src /free_claude_code /config /env_template.py
dheraingoud's picture
feat: synchronize proxy with upstream commits up to 5305bd7 and integrate NIM key rotator
0a54372
Raw
History Blame Contribute Delete
884 Bytes
"""Canonical env template loading for init and Admin UI defaults."""
import importlib.resources
from pathlib import Path
def load_env_template() -> str:
"""Load the root ``.env.example`` template from wheel resources or checkout."""
packaged = importlib.resources.files("free_claude_code.config").joinpath(
"env.example"
)
if packaged.is_file():
return packaged.read_text("utf-8")
source_template = Path(__file__).resolve().parents[3] / ".env.example"
if source_template.is_file():
return source_template.read_text(encoding="utf-8")
raise FileNotFoundError("Could not find bundled or source .env.example template.")
def load_env_template_or_empty() -> str:
"""Return the env template, or an empty template when unavailable."""
try:
return load_env_template()
except FileNotFoundError:
return ""