fs.copy¶
Functions for copying resources between filesystem.
-
fs.copy.
copy_dir
(src_fs, src_path, dst_fs, dst_path, walker=None, on_copy=None)¶ Copy a directory from one filesystem to another.
Parameters: - src_fs (FS or str) – Source filesystem (instance or URL).
- src_path (str) – Path to a directory on the source filesystem.
- dst_fs (FS or str) – Destination filesystem (instance or URL).
- dst_path (str) – Path to a directory on the destination filesystem.
- walker (Walker, optional) – A walker object that will be
used to scan for files in
src_fs
. Set this if you only want to consider a sub-set of the resources insrc_fs
. - on_copy (callable, optional) – A function callback called after
a single file copy is executed. Expected signature is
(src_fs, src_path, dst_fs, dst_path)
.
-
fs.copy.
copy_dir_if_newer
(src_fs, src_path, dst_fs, dst_path, walker=None, on_copy=None)¶ Copy a directory from one filesystem to another, checking times.
If both source and destination files exist, the copy is executed only if the source file is newer than the destination file. In case modification times of source or destination files are not available, copy is always executed.
Parameters: - src_fs (FS or str) – Source filesystem (instance or URL).
- src_path (str) – Path to a directory on the source filesystem.
- dst_fs (FS or str) – Destination filesystem (instance or URL).
- dst_path (str) – Path to a directory on the destination filesystem.
- walker (Walker, optional) – A walker object that will be
used to scan for files in
src_fs
. Set this if you only want to consider a sub-set of the resources insrc_fs
. - on_copy (callable, optional) – A function callback called after
a single file copy is executed. Expected signature is
(src_fs, src_path, dst_fs, dst_path)
.
-
fs.copy.
copy_file
(src_fs, src_path, dst_fs, dst_path)¶ Copy a file from one filesystem to another.
If the destination exists, and is a file, it will be first truncated.
Parameters:
-
fs.copy.
copy_file_if_newer
(src_fs, src_path, dst_fs, dst_path)¶ Copy a file from one filesystem to another, checking times.
If the destination exists, and is a file, it will be first truncated. If both source and destination files exist, the copy is executed only if the source file is newer than the destination file. In case modification times of source or destination files are not available, copy is always executed.
Parameters: Returns: Return type:
-
fs.copy.
copy_fs
(src_fs, dst_fs, walker=None, on_copy=None)¶ Copy the contents of one filesystem to another.
Parameters: - src_fs (FS or str) – Source filesystem (URL or instance).
- dst_fs (FS or str) – Destination filesystem (URL or instance).
- walker (Walker, optional) – A walker object that will be
used to scan for files in
src_fs
. Set this if you only want to consider a sub-set of the resources insrc_fs
. - on_copy (callable) – A function callback called after a single file copy
is executed. Expected signature is
(src_fs, src_path, dst_fs, dst_path)
.
-
fs.copy.
copy_fs_if_newer
(src_fs, dst_fs, walker=None, on_copy=None)¶ Copy the contents of one filesystem to another, checking times.
If both source and destination files exist, the copy is executed only if the source file is newer than the destination file. In case modification times of source or destination files are not available, copy file is always executed.
Parameters: - src_fs (FS or str) – Source filesystem (URL or instance).
- dst_fs (FS or str) – Destination filesystem (URL or instance).
- walker (Walker, optional) – A walker object that will be
used to scan for files in
src_fs
. Set this if you only want to consider a sub-set of the resources insrc_fs
. - on_copy (callable) – A function callback called after a single file copy
is executed. Expected signature is
(src_fs, src_path, dst_fs, dst_path)
.
-
fs.copy.
copy_structure
(src_fs, dst_fs, walker=None)¶ Copy directories (but not files) from
src_fs
todst_fs
.Parameters: