Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d4a853

Browse files
committed
Changed 'copy_file()' so it returns a tuple (dest_name, copied) -- hopefully,
this will please everyone (as if that's possible).
1 parent ec84c21 commit 0d4a853

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Lib/distutils/file_util.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ def copy_file (src, dst,
9595
Under Mac OS, uses the native file copy function in macostools; on
9696
other systems, uses '_copy_file_contents()' to copy file contents.
9797
98-
Return the name of the destination file, whether it was actually copied
99-
or not.
98+
Return a tuple (dest_name, copied): 'dest_name' is the actual name of
99+
the output file, and 'copied' is true if the file was copied (or would
100+
have been copied, if 'dry_run' true).
100101
"""
101102
# XXX if the destination file already exists, we clobber it if
102103
# copying, but blow up if linking. Hmmm. And I don't know what
@@ -121,7 +122,7 @@ def copy_file (src, dst,
121122
if update and not newer(src, dst):
122123
if verbose:
123124
print "not copying %s (output up-to-date)" % src
124-
return dst
125+
return (dst, 0)
125126

126127
try:
127128
action = _copy_action[link]
@@ -135,9 +136,9 @@ def copy_file (src, dst,
135136
print "%s %s -> %s" % (action, src, dst)
136137

137138
if dry_run:
138-
return dst
139+
return (dst, 1)
139140

140-
# On a Mac, use the native file copy routine
141+
# On Mac OS, use the native file copy routine
141142
if os.name == 'mac':
142143
import macostools
143144
try:
@@ -169,7 +170,7 @@ def copy_file (src, dst,
169170
if preserve_mode:
170171
os.chmod(dst, S_IMODE(st[ST_MODE]))
171172

172-
return dst
173+
return (dst, 1)
173174

174175
# copy_file ()
175176

0 commit comments

Comments
 (0)