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

Function _modify_data

dvc/utils/serialize/_common.py:82–91  ·  view source on GitHub ↗
(
    path: "StrPath",
    parser: ParserFn,
    dumper: DumpersFn,
    fs: Optional["FileSystem"] = None,
)

Source from the content-addressed store, hash-verified

80
81@contextmanager
82def _modify_data(
83 path: "StrPath",
84 parser: ParserFn,
85 dumper: DumpersFn,
86 fs: Optional["FileSystem"] = None,
87):
88 file_exists = fs.exists(os.fspath(path)) if fs else os.path.exists(path)
89 data = _load_data(path, parser=parser, fs=fs) if file_exists else {}
90 yield data
91 _dump_data(path, data, dumper=dumper, fs=fs)

Callers 4

modify_jsonFunction · 0.85
modify_yamlFunction · 0.85
modify_pyFunction · 0.85
modify_tomlFunction · 0.85

Calls 4

_load_dataFunction · 0.85
_dump_dataFunction · 0.85
existsMethod · 0.45
fspathMethod · 0.45

Tested by

no test coverage detected