MCPcopy Create free account
hub / github.com/OpenDCAI/DataFlow-MM / copy_file

Function copy_file

dataflow/cli_funcs/copy_funcs.py:5–21  ·  view source on GitHub ↗

Copy a single file with path, with checking and asking about the existence.

(source: Path, destination: Path)

Source from the content-addressed store, hash-verified

3from pathlib import Path
4
5def copy_file(source: Path, destination: Path):
6 """
7 Copy a single file with path, with checking and asking about the existence.
8 """
9 if not source.is_file():
10 print(f"Error: {source} is not a file.")
11 return
12
13 if destination.exists():
14 print(f"Warning: {destination.name} already exists in {destination.parent}.")
15 user_input = input(f"Do you want to overwrite {destination.name}? (y/n): ").strip().lower()
16 if user_input != 'y':
17 print(f"Skipping {destination.name}.")
18 return
19
20 shutil.copy(source, destination)
21 print(f"Copied {source.name} to {destination}.")
22
23def copy_files_without_recursion(source: Path, destination):
24 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected