MCPcopy Index your code
hub / github.com/RustPython/RustPython / absolute

Method absolute

Lib/pathlib/__init__.py:894–922  ·  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

892 yield self._from_parsed_string(path_str), dirnames, filenames
893
894 def absolute(self):
895 """Return an absolute version of this path
896 No normalization or symlink resolution is performed.
897
898 Use resolve() to resolve symlinks and remove '..' segments.
899 """
900 if self.is_absolute():
901 return self
902 if self.root:
903 drive = os.path.splitroot(os.getcwd())[0]
904 return self._from_parsed_parts(drive, self.root, self._tail)
905 if self.drive:
906 # There is a CWD on each drive-letter drive.
907 cwd = os.path.abspath(self.drive)
908 else:
909 cwd = os.getcwd()
910 if not self._tail:
911 # Fast path for "empty" paths, e.g. Path("."), Path("") or Path().
912 # We pass only one argument to with_segments() to avoid the cost
913 # of joining, and we exploit the fact that getcwd() returns a
914 # fully-normalized string by storing it in _str. This is used to
915 # implement Path.cwd().
916 return self._from_parsed_string(cwd)
917 drive, root, rel = os.path.splitroot(cwd)
918 if not rel:
919 return self._from_parsed_parts(drive, root, self._tail)
920 tail = rel.split(self.parser.sep)
921 tail.extend(self._tail)
922 return self._from_parsed_parts(drive, root, tail)
923
924 @classmethod
925 def cwd(cls):

Callers 10

_normalize_uriFunction · 0.95
test_filesMethod · 0.80
test_search_pathMethod · 0.80
test_search_path_exeMethod · 0.80
test_absolute_commonMethod · 0.80
test_with_segmentsMethod · 0.80
test_absolute_posixMethod · 0.80
test_absolute_windowsMethod · 0.80

Calls 5

is_absoluteMethod · 0.80
_from_parsed_partsMethod · 0.80
_from_parsed_stringMethod · 0.80
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