MCPcopy Create free account
hub / github.com/DonnieDice/protondrive-linux / atomic_write

Function atomic_write

scripts/ci/apply-doc-patch.py:37–46  ·  view source on GitHub ↗
(path: str, content: str)

Source from the content-addressed store, hash-verified

35
36
37def atomic_write(path: str, content: str) -> None:
38 directory = os.path.dirname(path) or "."
39 fd, tmp_path = tempfile.mkstemp(prefix=".doc-update.", dir=directory, text=True)
40 try:
41 with os.fdopen(fd, "w", encoding="utf-8", newline="\n") as f:
42 f.write(content)
43 os.replace(tmp_path, path)
44 finally:
45 if os.path.exists(tmp_path):
46 os.unlink(tmp_path)
47
48
49def main() -> int:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected