MCPcopy
hub / github.com/treeverse/dvc / atomic_file

Function atomic_file

dvc/database.py:41–45  ·  view source on GitHub ↗
(file: StrOrBytesPath, mode: str = "w+b")

Source from the content-addressed store, hash-verified

39
40@contextmanager
41def atomic_file(file: StrOrBytesPath, mode: str = "w+b"):
42 head, tail = os.path.split(os.fsdecode(file))
43 with NamedTemporaryFile(mode, prefix=tail + "-", dir=head, delete=False) as f:
44 yield f
45 os.replace(f.name, file)
46
47
48@dataclass

Callers 2

to_csvMethod · 0.85
to_jsonMethod · 0.85

Calls 1

replaceMethod · 0.45

Tested by

no test coverage detected