Lines Matching refs:path
34 def _get_bothseps(path): argument
35 if isinstance(path, bytes):
77 def join(path, *paths): argument
78 path = os.fspath(path)
79 if isinstance(path, bytes):
89 path[:0] + sep #23780: Ensure compatible data type even if p is null.
90 result_drive, result_path = splitdrive(path)
117 genericpath._check_arg_types('join', path, *paths)
228 def islink(path): argument
233 st = os.lstat(path)
240 def lexists(path): argument
243 st = os.lstat(path)
262 def ismount(path): argument
265 path = os.fspath(path)
266 seps = _get_bothseps(path)
267 path = abspath(path)
268 root, rest = splitdrive(path)
275 return path.rstrip(seps) == _getvolumepathname(path).rstrip(seps)
289 def expanduser(path): argument
293 path = os.fspath(path)
294 if isinstance(path, bytes):
298 if not path.startswith(tilde):
299 return path
300 i, n = 1, len(path)
301 while i < n and path[i] not in _get_bothseps(path):
307 return path
316 target_user = path[1:i]
328 return path
331 if isinstance(path, bytes):
334 return userhome + path[i:]
350 def expandvars(path): argument
354 path = os.fspath(path)
355 if isinstance(path, bytes):
356 if b'$' not in path and b'%' not in path:
357 return path
367 if '$' not in path and '%' not in path:
368 return path
377 res = path[:0]
379 pathlen = len(path)
381 c = path[index:index+1]
383 path = path[index + 1:]
384 pathlen = len(path)
386 index = path.index(c)
387 res += c + path[:index + 1]
389 res += c + path
392 if path[index + 1:index + 2] == percent:
396 path = path[index+1:]
397 pathlen = len(path)
399 index = path.index(percent)
401 res += percent + path
404 var = path[:index]
414 if path[index + 1:index + 2] == dollar:
417 elif path[index + 1:index + 2] == brace:
418 path = path[index+2:]
419 pathlen = len(path)
421 index = path.index(rbrace)
423 res += dollar + brace + path
426 var = path[:index]
436 var = path[:0]
438 c = path[index:index + 1]
442 c = path[index:index + 1]
463 def normpath(path): argument
465 path = os.fspath(path)
466 if isinstance(path, bytes):
478 if path.startswith(special_prefixes):
484 return path
485 path = path.replace(altsep, sep)
486 prefix, path = splitdrive(path)
489 if path.startswith(sep):
491 path = path.lstrip(sep)
493 comps = path.split(sep)
513 def _abspath_fallback(path): argument
520 path = os.fspath(path)
521 if not isabs(path):
522 if isinstance(path, bytes):
526 path = join(cwd, path)
527 return normpath(path)
537 def abspath(path): argument
540 return normpath(_getfullpathname(path))
542 return _abspath_fallback(path)
550 def _readlink_deep(path): argument
568 while normcase(path) not in seen:
569 seen.add(normcase(path))
571 old_path = path
572 path = _nt_readlink(path)
575 if not isabs(path):
580 path = old_path
582 path = normpath(join(dirname(old_path), path))
590 return path
592 def _getfinalpathname_nonstrict(path): argument
612 while path:
614 path = _getfinalpathname(path)
615 return join(path, tail) if tail else path
623 new_path = _readlink_deep(path)
624 if new_path != path:
629 path, name = split(path)
633 if path and not name:
634 return path + tail
638 def realpath(path, *, strict=False): argument
639 path = normpath(path)
640 if isinstance(path, bytes):
646 if normcase(path) == normcase(os.fsencode(devnull)):
654 if normcase(path) == normcase(devnull):
656 had_prefix = path.startswith(prefix)
657 if not had_prefix and not isabs(path):
658 path = join(cwd, path)
660 path = _getfinalpathname(path)
666 path = _getfinalpathname_nonstrict(path)
670 if not had_prefix and path.startswith(prefix):
673 if path.startswith(unc_prefix):
674 spath = new_unc_prefix + path[len(unc_prefix):]
676 spath = path[len(prefix):]
679 if _getfinalpathname(spath) == path:
680 path = spath
685 path = spath
686 return path
693 def relpath(path, start=None): argument
695 path = os.fspath(path)
696 if isinstance(path, bytes):
708 if not path:
714 path_abs = abspath(normpath(path))
735 genericpath._check_arg_types('relpath', path, start)
780 drive, path = splitdrive(paths[0].replace(altsep, sep))
781 common = path.split(sep)