Lines Matching refs:src

202 def _samefile(src, dst):
204 if isinstance(src, os.DirEntry) and hasattr(os.path, 'samestat'):
206 return os.path.samestat(src.stat(), os.stat(dst))
212 return os.path.samefile(src, dst)
217 return (os.path.normcase(os.path.abspath(src)) ==
226 def copyfile(src, dst, *, follow_symlinks=True):
227 """Copy data from src to dst in the most efficient way possible.
229 If follow_symlinks is not set and src is a symbolic link, a new
233 sys.audit("shutil.copyfile", src, dst)
235 if _samefile(src, dst):
236 raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
239 for i, fn in enumerate([src, dst]):
253 if not follow_symlinks and _islink(src):
254 os.symlink(os.readlink(src), dst)
256 with open(src, 'rb') as fsrc:
290 def copymode(src, dst, *, follow_symlinks=True):
291 """Copy mode bits from src to dst.
294 if both `src` and `dst` are symlinks. If `lchmod` isn't available
298 sys.audit("shutil.copymode", src, dst)
300 if not follow_symlinks and _islink(src) and os.path.islink(dst):
308 st = stat_func(src)
312 def _copyxattr(src, dst, *, follow_symlinks=True):
313 """Copy extended filesystem attributes from `src` to `dst`.
322 names = os.listxattr(src, follow_symlinks=follow_symlinks)
329 value = os.getxattr(src, name, follow_symlinks=follow_symlinks)
339 def copystat(src, dst, *, follow_symlinks=True):
343 flags from `src` to `dst`. On Linux, copystat() also copies the "extended
345 unaffected. `src` and `dst` are path-like objects or path names given as
349 followed if and only if both `src` and `dst` are symlinks.
351 sys.audit("shutil.copystat", src, dst)
357 follow = follow_symlinks or not (_islink(src) and os.path.islink(dst))
371 if isinstance(src, os.DirEntry):
372 st = src.stat(follow_symlinks=follow)
374 st = lookup("stat")(src, follow_symlinks=follow)
380 _copyxattr(src, dst, follow_symlinks=follow)
405 def copy(src, dst, *, follow_symlinks=True):
406 """Copy data and mode bits ("cp src dst"). Return the file's destination.
411 resembles GNU's "cp -P src dst".
418 dst = os.path.join(dst, os.path.basename(src))
419 copyfile(src, dst, follow_symlinks=follow_symlinks)
420 copymode(src, dst, follow_symlinks=follow_symlinks)
423 def copy2(src, dst, *, follow_symlinks=True):
432 resembles GNU's "cp -P src dst".
435 dst = os.path.join(dst, os.path.basename(src))
436 copyfile(src, dst, follow_symlinks=follow_symlinks)
437 copystat(src, dst, follow_symlinks=follow_symlinks)
452 def _copytree(entries, src, dst, symlinks, ignore, copy_function,
455 ignored_names = ignore(os.fspath(src), [x.name for x in entries])
466 srcname = os.path.join(src, srcentry.name)
509 copystat(src, dst)
513 errors.append((src, dst, str(why)))
518 def copytree(src, dst, symlinks=False, ignore=None, copy_function=copy2,
536 is called with the `src` parameter, which is the directory
538 `src` contents, as returned by os.listdir():
540 callable(src, names) -> ignored_names
544 list of names relative to the `src` directory that should
556 `src` tree.
558 sys.audit("shutil.copytree", src, dst)
559 with os.scandir(src) as itr:
561 return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
783 def move(src, dst, copy_function=copy2):
796 Otherwise, src is copied to the destination and then removed. Symlinks are
809 sys.audit("shutil.move", src, dst)
812 if _samefile(src, dst):
815 os.rename(src, dst)
820 real_dst = os.path.join(dst, _basename(src))
825 os.rename(src, real_dst)
827 if os.path.islink(src):
828 linkto = os.readlink(src)
830 os.unlink(src)
831 elif os.path.isdir(src):
832 if _destinsrc(src, dst):
834 " '%s'." % (src, dst))
835 if (_is_immutable(src)
836 or (not os.access(src, os.W_OK) and os.listdir(src)
840 % (src, src))
841 copytree(src, real_dst, copy_function=copy_function,
843 rmtree(src)
845 copy_function(src, real_dst)
846 os.unlink(src)
849 def _destinsrc(src, dst):
850 src = os.path.abspath(src)
852 if not src.endswith(os.path.sep):
853 src += os.path.sep
856 return dst.startswith(src)
858 def _is_immutable(src):
859 st = _stat(src)