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

Function copy_files_without_recursion

dataflow/cli_funcs/copy_funcs.py:23–52  ·  view source on GitHub ↗

Copy files under a path without recursion, with checking and asking about the existence.

(source: Path, destination)

Source from the content-addressed store, hash-verified

21 print(f"Copied {source.name} to {destination}.")
22
23def copy_files_without_recursion(source: Path, destination):
24 """
25 Copy files under a path without recursion, with checking and asking about the existence.
26 """
27 yes_to_all, none_to_all = False, False
28
29 for template_file in source.iterdir():
30 if template_file.is_file():
31 if template_file.name == "__init__.py":
32 continue # skip __init__.py files
33 destination_file = Path(destination) / template_file.name
34 if destination_file.exists():
35 if none_to_all:
36 print(f' Skipping {template_file.name}.\n')
37 continue
38 if not yes_to_all:
39 # Alert , whether overwrite?
40 print(f' {Fore.YELLOW}Warning: {template_file.name} already exists in {destination}.{Style.RESET_ALL}')
41 user_input = input(f' Do you want to overwrite {template_file.name}? (y/n/all/none): ').strip().lower()
42 if user_input == 'all':
43 yes_to_all = True
44 elif user_input == 'none':
45 none_to_all = True
46 print(f' Skipping {template_file.name}.\n')
47 continue
48 elif user_input != 'y':
49 print(f' Skipping {template_file.name}.\n')
50 continue
51 shutil.copy(template_file, destination_file)
52 print(f' Copied {template_file.name} to {destination}.\n')
53
54def copy_files_recursively(source_path: Path, destination_path: Path):
55 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected