MCPcopy Index your code
hub / github.com/python/cpython / absolute

Method absolute

Lib/pathlib/__init__.py:1092–1120  ·  view source on GitHub ↗

Return an absolute version of this path No normalization or symlink resolution is performed. Use resolve() to resolve symlinks and remove '..' segments.

(self)

Source from the content-addressed store, hash-verified

1090 yield self._from_parsed_string(path_str), dirnames, filenames
1091
1092 def absolute(self):
1093 """Return an absolute version of this path
1094 No normalization or symlink resolution is performed.
1095
1096 Use resolve() to resolve symlinks and remove '..' segments.
1097 """
1098 if self.is_absolute():
1099 return self
1100 if self.root:
1101 drive = os.path.splitroot(os.getcwd())[0]
1102 return self._from_parsed_parts(drive, self.root, self._tail)
1103 if self.drive:
1104 # There is a CWD on each drive-letter drive.
1105 cwd = os.path.abspath(self.drive)
1106 else:
1107 cwd = os.getcwd()
1108 if not self._tail:
1109 # Fast path for "empty" paths, e.g. Path("."), Path("") or Path().
1110 # We pass only one argument to with_segments() to avoid the cost
1111 # of joining, and we exploit the fact that getcwd() returns a
1112 # fully-normalized string by storing it in _str. This is used to
1113 # implement Path.cwd().
1114 return self._from_parsed_string(cwd)
1115 drive, root, rel = os.path.splitroot(cwd)
1116 if not rel:
1117 return self._from_parsed_parts(drive, root, self._tail)
1118 tail = rel.split(self.parser.sep)
1119 tail.extend(self._tail)
1120 return self._from_parsed_parts(drive, root, tail)
1121
1122 @classmethod
1123 def cwd(cls):

Callers 15

_normalize_uriFunction · 0.95
emsdk_cache_rootFunction · 0.80
get_build_pathsFunction · 0.80
mainFunction · 0.80
wasm_assets.pyFile · 0.80
pathFunction · 0.80
make_wasi_pythonFunction · 0.80
test_filesMethod · 0.80
test_search_pathMethod · 0.80
test_search_path_exeMethod · 0.80
test_getpath.pyFile · 0.80

Calls 6

is_absoluteMethod · 0.80
_from_parsed_partsMethod · 0.80
_from_parsed_stringMethod · 0.80
abspathMethod · 0.45
splitMethod · 0.45
extendMethod · 0.45

Tested by 9

test_filesMethod · 0.64
test_search_pathMethod · 0.64
test_search_path_exeMethod · 0.64
test_absolute_commonMethod · 0.64
test_with_segmentsMethod · 0.64
test_absolute_posixMethod · 0.64
test_absolute_windowsMethod · 0.64