MCPcopy Create free account
hub / github.com/ZyphrZero/z.ai2api_python / reset_env_to_example

Function reset_env_to_example

app/admin/config_manager.py:659–682  ·  view source on GitHub ↗
(
    *,
    reload_callback: ReloadCallback,
    env_path: str | Path = ENV_PATH,
    env_example_path: str | Path = ENV_EXAMPLE_PATH,
)

Source from the content-addressed store, hash-verified

657
658
659async def reset_env_to_example(
660 *,
661 reload_callback: ReloadCallback,
662 env_path: str | Path = ENV_PATH,
663 env_example_path: str | Path = ENV_EXAMPLE_PATH,
664) -> None:
665 example_path = Path(env_example_path)
666 if not example_path.exists():
667 raise FileNotFoundError(".env.example 不存在")
668
669 example_content = example_path.read_text(encoding="utf-8")
670
671 def _writer(target_path: Path) -> None:
672 content = example_content.rstrip("\n")
673 target_path.write_text(
674 f"{content}\n" if content else "",
675 encoding="utf-8",
676 )
677
678 await _apply_env_change(
679 _writer,
680 reload_callback=reload_callback,
681 env_path=env_path,
682 )

Callers 1

reset_configFunction · 0.90

Calls 1

_apply_env_changeFunction · 0.85

Tested by

no test coverage detected