Return an absolute version of this path No normalization or symlink resolution is performed. Use resolve() to resolve symlinks and remove '..' segments.
(self)
| 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): |