Home | History | Annotate | Download | only in distutils

Lines Matching refs:dst

18 def _copy_file_contents(src, dst, buffer_size=16*1024):
19 """Copy the file 'src' to 'dst'.
22 'src', or writing to 'dst', raises DistutilsFileError. Data is
36 if os.path.exists(dst):
38 os.unlink(dst)
41 "could not delete '%s': %s" % (dst, errstr))
44 fdst = open(dst, 'wb')
47 "could not create '%s': %s" % (dst, errstr))
63 "could not write to '%s': %s" % (dst, errstr))
71 def copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0,
73 """Copy a file 'src' to 'dst'.
75 If 'dst' is a directory, then 'src' is copied there with the same name;
81 If 'update' is true, 'src' will only be copied if 'dst' does not exist,
82 or if 'dst' does exist but is older than 'src'.
103 # (not update) and (src newer than dst).
112 if os.path.isdir(dst):
113 dir = dst
114 dst = os.path.join(dst, os.path.basename(src))
116 dir = os.path.dirname(dst)
118 if update and not newer(src, dst):
121 return dst, 0
129 if os.path.basename(dst) == os.path.basename(src):
132 log.info("%s %s -> %s", action, src, dst)
135 return (dst, 1)
140 if not (os.path.exists(dst) and os.path.samefile(src, dst)):
142 os.link(src, dst)
143 return (dst, 1)
150 if not (os.path.exists(dst) and os.path.samefile(src, dst)):
151 os.symlink(src, dst)
152 return (dst, 1)
156 _copy_file_contents(src, dst)
163 os.utime(dst, (st[ST_ATIME], st[ST_MTIME]))
165 os.chmod(dst, S_IMODE(st[ST_MODE]))
167 return (dst, 1)
170 def move_file (src, dst, verbose=1, dry_run=0):
171 """Move a file 'src' to 'dst'.
173 If 'dst' is a directory, the file will be moved into it with the same
174 name; otherwise, 'src' is just renamed to 'dst'. Return the new
184 log.info("moving %s -> %s", src, dst)
187 return dst
192 if isdir(dst):
193 dst = os.path.join(dst, basename(src))
194 elif exists(dst):
197 (src, dst))
199 if not isdir(dirname(dst)):
202 (src, dst))
206 os.rename(src, dst)
212 "couldn't move '%s' to '%s': %s" % (src, dst, msg))
215 copy_file(src, dst, verbose=verbose)
220 os.unlink(dst)
226 (src, dst, src, msg))
227 return dst