Lines Matching full:path

204     if isinstance(src, os.DirEntry) and hasattr(os.path, 'samestat'):
206 return os.path.samestat(src.stat(), os.stat(dst))
210 if hasattr(os.path, 'samefile'):
212 return os.path.samefile(src, dst)
217 return (os.path.normcase(os.path.abspath(src)) ==
218 os.path.normcase(os.path.abspath(dst)))
224 return fn.is_symlink() if isinstance(fn, os.DirEntry) else os.path.islink(fn)
248 fn = fn.path if isinstance(fn, os.DirEntry) else fn
283 if not os.path.exists(dst):
300 if not follow_symlinks and _islink(src) and os.path.islink(dst):
345 unaffected. `src` and `dst` are path-like objects or path names given as
357 follow = follow_symlinks or not (_islink(src) and os.path.islink(dst))
417 if os.path.isdir(dst):
418 dst = os.path.join(dst, os.path.basename(src))
434 if os.path.isdir(dst):
435 dst = os.path.join(dst, os.path.basename(src))
445 def _ignore_patterns(path, names):
466 srcname = os.path.join(src, srcentry.name)
467 dstname = os.path.join(dst, srcentry.name)
487 if not os.path.exists(linkto) and ignore_dangling_symlinks:
548 to copy each file. It will be called with the source path and the
549 destination path as arguments. By default, copy2() is used, but any
579 def _rmtree_islink(path):
581 st = os.lstat(path)
594 def _rmtree_islink(path):
595 return os.path.islink(path)
598 def _rmtree_unsafe(path, onerror):
600 with os.scandir(path) as scandir_it:
603 onerror(os.scandir, path, sys.exc_info())
606 fullname = entry.path
615 onerror(os.path.islink, fullname, sys.exc_info())
624 os.rmdir(path)
626 onerror(os.rmdir, path, sys.exc_info())
629 def _rmtree_safe_fd(topfd, path, onerror):
634 err.filename = path
635 onerror(os.scandir, path, sys.exc_info())
638 fullname = os.path.join(path, entry.name)
659 if os.path.samestat(orig_st, os.fstat(dirfd)):
675 onerror(os.path.islink, fullname, sys.exc_info())
690 def rmtree(path, ignore_errors=False, onerror=None, *, dir_fd=None):
694 path will then be relative to that directory.
700 path, exc_info) where func is platform and implementation dependent;
701 path is the argument to that function that caused it to fail; and
706 sys.audit("shutil.rmtree", path, dir_fd)
715 if isinstance(path, bytes):
716 path = os.fsdecode(path)
720 orig_st = os.lstat(path, dir_fd=dir_fd)
722 onerror(os.lstat, path, sys.exc_info())
725 fd = os.open(path, os.O_RDONLY, dir_fd=dir_fd)
728 onerror(os.open, path, sys.exc_info())
731 if os.path.samestat(orig_st, os.fstat(fd)):
732 _rmtree_safe_fd(fd, path, onerror)
736 os.rmdir(path, dir_fd=dir_fd)
738 onerror(os.rmdir, path, sys.exc_info())
744 onerror(os.path.islink, path, sys.exc_info())
752 if _rmtree_islink(path):
756 onerror(os.path.islink, path, sys.exc_info())
759 return _rmtree_unsafe(path, onerror)
765 def _basename(path):
767 Thus we always get the last component of the path, even for directories.
769 path: Union[PathLike, str]
772 >>> os.path.basename('/bar/foo')
774 >>> os.path.basename('/bar/foo/')
779 path = os.fspath(path)
780 sep = os.path.sep + (os.path.altsep or '')
781 return os.path.basename(path.rstrip(sep))
789 is moved inside the directory. The destination path must not already
811 if os.path.isdir(dst):
818 # Using _basename instead of os.path.basename is important, as we must
820 real_dst = os.path.join(dst, _basename(src))
822 if os.path.exists(real_dst):
823 raise Error("Destination path '%s' already exists" % real_dst)
827 if os.path.islink(src):
831 elif os.path.isdir(src):
850 src = os.path.abspath(src)
851 dst = os.path.abspath(dst)
852 if not src.endswith(os.path.sep):
853 src += os.path.sep
854 if not dst.endswith(os.path.sep):
855 dst += os.path.sep
931 archive_dir = os.path.dirname(archive_name)
933 if archive_dir and not os.path.exists(archive_dir):
959 base_dir = os.path.join(root_dir, base_dir)
966 archive_name = os.path.abspath(archive_name)
979 archive_dir = os.path.dirname(base_name)
981 if archive_dir and not os.path.exists(archive_dir):
994 arcname = os.path.normpath(base_dir)
996 base_dir = os.path.join(root_dir, base_dir)
997 base_dir = os.path.normpath(base_dir)
1005 arcdirpath = os.path.relpath(arcdirpath, root_dir)
1006 arcdirpath = os.path.normpath(arcdirpath)
1008 path = os.path.join(dirpath, name)
1009 arcname = os.path.join(arcdirpath, name)
1010 zf.write(path, arcname)
1012 logger.info("adding '%s'", path)
1014 path = os.path.join(dirpath, name)
1015 path = os.path.normpath(path)
1016 if os.path.isfile(path):
1017 arcname = os.path.join(arcdirpath, name)
1018 zf.write(path, arcname)
1020 logger.info("adding '%s'", path)
1023 zip_filename = os.path.abspath(zip_filename)
1121 # Support path-like base_name here for backwards-compatibility.
1128 base_name = os.path.abspath(base_name)
1198 def _ensure_directory(path):
1199 """Ensure that the parent directory of `path` exists"""
1200 dirname = os.path.dirname(path)
1201 if not os.path.isdir(dirname):
1221 targetpath = os.path.join(extract_dir, *name.split('/'))
1334 def disk_usage(path):
1335 """Return disk usage statistics about the given path.
1340 st = os.statvfs(path)
1351 def disk_usage(path):
1352 """Return disk usage statistics about the given path.
1357 total, free = nt._getdiskusage(path)
1362 def chown(path, user=None, group=None):
1363 """Change owner user and group of the given path.
1368 sys.audit('shutil.chown', path, user, group)
1392 os.chown(path, _user, _group)
1444 return (os.path.exists(fn) and os.access(fn, mode)
1445 and not os.path.isdir(fn))
1448 def which(cmd, mode=os.F_OK | os.X_OK, path=None):
1449 """Given a command, mode, and a PATH string, return the path which
1450 conforms to the given mode on the PATH, or None if there is no such
1453 `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
1454 of os.environ.get("PATH"), or can be overridden with a custom search
1455 path.
1458 # If we're given a path with a directory part, look it up directly rather
1459 # than referring to PATH directories. This includes checking relative to the
1461 if os.path.dirname(cmd):
1468 if path is None:
1469 path = os.environ.get("PATH", None)
1470 if path is None:
1472 path = os.confstr("CS_PATH")
1475 path = os.defpath
1476 # bpo-35755: Don't use os.defpath if the PATH environment variable is
1479 # PATH='' doesn't match, whereas PATH=':' looks in the current directory
1480 if not path:
1484 path = os.fsencode(path)
1485 path = path.split(os.fsencode(os.pathsep))
1487 path = os.fsdecode(path)
1488 path = path.split(os.pathsep)
1495 if curdir not in path:
1496 path.insert(0, curdir)
1504 # See if the given file matches any of the expected path extensions.
1518 for dir in path:
1519 normdir = os.path.normcase(dir)
1523 name = os.path.join(dir, thefile)