9 examples of 'python copy directory' in Python

Every line of 'python copy directory' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
69def copy_pyodide(pyodide_dir, demo_dir):
70 if not os.path.isdir(pyodide_dir):
71 print(f'Pyodide directory {pyodide_dir!r} not found.')
72 return
73
74 for file_name in ('pyodide.js',
75 'pyodide.asm.wasm',
76 'pyodide.asm.js',
77 'pyodide.asm.data.js',
78 'pyodide.asm.data',
79 'packages.json'):
80 source_path = os.path.join(pyodide_dir, 'build', file_name)
81 target_path = os.path.join(demo_dir, 'pyodide', file_name)
82 copy_if_needed(source_path, target_path)
132def CopyDir(src, dst):
133 try:
134 print "copying directory", src, "to", dst, "..."
135 shutil.rmtree(dst, True)
136 shutil.copytree(src, dst)
137 except OSError, err:
138 FatalError("ERROR: Could not copy %s to %s: %s\n" % (src, dst, err))
43def copy_source_files():
44 for f in SOURCE_FILES:
45 dirname, filename = os.path.split(f)
46 target_dirname = os.path.join('package', dirname)
47 os.makedirs(target_dirname, exist_ok=True)
48 shutil.copy(f, target_dirname)
252def copydir(src, dst, with_src=True):
253 # Example call: scp -r foo your_username@remotehost.edu:/some/scripts/directory/bar
254 # print("Transfering files ...")
255 mkdirs(dst)
256 if not with_src:
257 src += '/'
258 subprocess.call(['rsync', '-uz', '-r', '-l', src, dst]) # scp / rsync, z compress, u update-mode
23def _copy(src, dst):
24 try:
25 shutil.copytree(src, dst)
26 except OSError as exc:
27 if exc.errno == errno.ENOTDIR:
28 shutil.copy(src, dst)
29 else:
30 raise
76def copy_files(path, files):
77 if files and not os.path.isdir(path):
78 _make_dir(path)
79 if not files:
80 return
81 for item in files:
82 msg = '%s -> %s' % (item, path)
83 if len(msg) > 80:
84 msg = '%s -> \n%s%s' % (item, ' ' * 10, path)
85 info(msg, CP_CODE)
86 if os.system('cp %s %s' % (item, path)):
87 raise IOError('Cannot copying %s -> %s' % (item, path))
70def copy_files(path, files):
71 if files and not os.path.isdir(path):
72 _make_dir(path)
73 if not files:
74 return
75 for item in files:
76 msg = '%s -> %s' % (item, path)
77 if len(msg) > 80:
78 msg = '%s -> \n%s%s' % (item, ' ' * 10, path)
79 LOG.log(CP_CODE, msg)
80 if os.system('cp %s %s' % (item, path)):
81 raise IOError('Cannot copying %s -> %s' % (item, path))
99def runpython_install(args):
100 destination_dir = os.path.expanduser("~") + '/Library/Application Scripts/com.microsoft.Excel'
101 if not os.path.exists(destination_dir):
102 os.makedirs(destination_dir)
103 shutil.copy(os.path.join(this_dir, 'xlwings.applescript'), destination_dir)
104 print('Successfully installed RunPython for Mac Excel 2016!')
81@staticmethod
82def Copy(directory,destinationPath,overwriteFiles):
83 """
84 Copy(directory: DirectoryInfo,destinationPath: str,overwriteFiles: bool)
85
86 Copies a directory to a destination location.
87
88
89
90 directory: Directory to copy.
91
92 destinationPath: Destination of the copy operation on disk.
93 """
94 pass

Related snippets