MCPcopy Create free account
hub / github.com/dot-agent/nextpy / cp

Function cp

nextpy/utils/path_ops.py:32–52  ·  view source on GitHub ↗

Copy a file or directory. Args: src: The path to the file or directory. dest: The path to the destination. overwrite: Whether to overwrite the destination. Returns: Whether the copy was successful.

(src: str, dest: str, overwrite: bool = True)

Source from the content-addressed store, hash-verified

30
31
32def cp(src: str, dest: str, overwrite: bool = True) -> bool:
33 """Copy a file or directory.
34
35 Args:
36 src: The path to the file or directory.
37 dest: The path to the destination.
38 overwrite: Whether to overwrite the destination.
39
40 Returns:
41 Whether the copy was successful.
42 """
43 if src == dest:
44 return False
45 if not overwrite and os.path.exists(dest):
46 return False
47 if os.path.isdir(src):
48 rm(dest)
49 shutil.copytree(src, dest)
50 else:
51 shutil.copyfile(src, dest)
52 return True
53
54
55def mv(src: str, dest: str, overwrite: bool = True) -> bool:

Callers

nothing calls this directly

Calls 1

rmFunction · 0.85

Tested by

no test coverage detected