MCPcopy Create free account
hub / github.com/github/spec-kit / _atomic_write_json

Method _atomic_write_json

src/specify_cli/workflows/engine.py:488–502  ·  view source on GitHub ↗

Write *data* as indented JSON to *path* atomically (temp + ``os.replace``).

(path: Path, data: dict[str, Any])

Source from the content-addressed store, hash-verified

486
487 @staticmethod
488 def _atomic_write_json(path: Path, data: dict[str, Any]) -> None:
489 """Write *data* as indented JSON to *path* atomically (temp + ``os.replace``)."""
490 fd, tmp = tempfile.mkstemp(
491 dir=str(path.parent), prefix=f".{path.name}.", suffix=".tmp"
492 )
493 try:
494 with os.fdopen(fd, "w", encoding="utf-8") as f:
495 json.dump(data, f, indent=2)
496 os.replace(tmp, path)
497 except BaseException:
498 try:
499 os.unlink(tmp)
500 except OSError:
501 pass
502 raise
503
504 @classmethod
505 def load(cls, run_id: str, project_root: Path) -> RunState:

Callers 1

saveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected