Skip to content

Commit 3a7de8f

Browse files
author
atollk
committed
Marked fs.copy.copy_*_if_newer as deprecated.
1 parent d3fb588 commit 3a7de8f

File tree

1 file changed

+7
-60
lines changed

1 file changed

+7
-60
lines changed

fs/copy.py

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from __future__ import print_function, unicode_literals
55

66
import typing
7+
import warnings
78

89
from .errors import ResourceNotFound
910
from .opener import manage_fs
@@ -52,26 +53,8 @@ def copy_fs_if_newer(
5253
workers=0, # type: int
5354
):
5455
# type: (...) -> None
55-
"""Copy the contents of one filesystem to another, checking times.
56-
57-
If both source and destination files exist, the copy is executed
58-
only if the source file is newer than the destination file. In case
59-
modification times of source or destination files are not available,
60-
copy file is always executed.
61-
62-
Arguments:
63-
src_fs (FS or str): Source filesystem (URL or instance).
64-
dst_fs (FS or str): Destination filesystem (URL or instance).
65-
walker (~fs.walk.Walker, optional): A walker object that will be
66-
used to scan for files in ``src_fs``. Set this if you only want
67-
to consider a sub-set of the resources in ``src_fs``.
68-
on_copy (callable):A function callback called after a single file copy
69-
is executed. Expected signature is ``(src_fs, src_path, dst_fs,
70-
dst_path)``.
71-
workers (int): Use ``worker`` threads to copy data, or ``0`` (default) for
72-
a single-threaded copy.
73-
74-
"""
56+
"""Deprecated. Use ``copy_fs_if``."""
57+
warnings.warn(DeprecationWarning("copy_fs_if_newer is deprecated. Use copy_fs_if instead."))
7558
return copy_fs_if(src_fs, dst_fs, "newer", walker, on_copy, workers)
7659

7760

@@ -157,24 +140,8 @@ def copy_file_if_newer(
157140
dst_path, # type: Text
158141
):
159142
# type: (...) -> bool
160-
"""Copy a file from one filesystem to another, checking times.
161-
162-
If the destination exists, and is a file, it will be first truncated.
163-
If both source and destination files exist, the copy is executed only
164-
if the source file is newer than the destination file. In case
165-
modification times of source or destination files are not available,
166-
copy is always executed.
167-
168-
Arguments:
169-
src_fs (FS or str): Source filesystem (instance or URL).
170-
src_path (str): Path to a file on the source filesystem.
171-
dst_fs (FS or str): Destination filesystem (instance or URL).
172-
dst_path (str): Path to a file on the destination filesystem.
173-
174-
Returns:
175-
bool: `True` if the file copy was executed, `False` otherwise.
176-
177-
"""
143+
"""Deprecated. Use ``copy_file_if``."""
144+
warnings.warn(DeprecationWarning("copy_file_if_newer is deprecated. Use copy_file_if instead."))
178145
return copy_file_if(src_fs, src_path, dst_fs, dst_path, "newer")
179146

180147

@@ -342,28 +309,8 @@ def copy_dir_if_newer(
342309
workers=0, # type: int
343310
):
344311
# type: (...) -> None
345-
"""Copy a directory from one filesystem to another, checking times.
346-
347-
If both source and destination files exist, the copy is executed only
348-
if the source file is newer than the destination file. In case
349-
modification times of source or destination files are not available,
350-
copy is always executed.
351-
352-
Arguments:
353-
src_fs (FS or str): Source filesystem (instance or URL).
354-
src_path (str): Path to a directory on the source filesystem.
355-
dst_fs (FS or str): Destination filesystem (instance or URL).
356-
dst_path (str): Path to a directory on the destination filesystem.
357-
walker (~fs.walk.Walker, optional): A walker object that will be
358-
used to scan for files in ``src_fs``. Set this if you only
359-
want to consider a sub-set of the resources in ``src_fs``.
360-
on_copy (callable, optional): A function callback called after
361-
a single file copy is executed. Expected signature is
362-
``(src_fs, src_path, dst_fs, dst_path)``.
363-
workers (int): Use ``worker`` threads to copy data, or ``0`` (default) for
364-
a single-threaded copy.
365-
366-
"""
312+
"""Deprecated. Use ``copy_dir_if``."""
313+
warnings.warn(DeprecationWarning("copy_dir_if_newer is deprecated. Use copy_dir_if instead."))
367314
copy_dir_if(src_fs, src_path, dst_fs, dst_path, "newer", walker, on_copy, workers)
368315

369316

0 commit comments

Comments
 (0)