MCPcopy Index your code
hub / github.com/ArchiveBox/ArchiveBox / copy_and_overwrite

Function copy_and_overwrite

archivebox/system.py:132–140  ·  view source on GitHub ↗

copy a given file or directory to a given path, overwriting the destination

(from_path: Union[str, Path], to_path: Union[str, Path])

Source from the content-addressed store, hash-verified

130
131@enforce_types
132def copy_and_overwrite(from_path: Union[str, Path], to_path: Union[str, Path]):
133 """copy a given file or directory to a given path, overwriting the destination"""
134 if Path(from_path).is_dir():
135 shutil.rmtree(to_path, ignore_errors=True)
136 shutil.copytree(from_path, to_path)
137 else:
138 with open(from_path, 'rb') as src:
139 contents = src.read()
140 atomic_write(to_path, contents)
141
142
143@enforce_types

Callers

nothing calls this directly

Calls 1

atomic_writeFunction · 0.85

Tested by

no test coverage detected