Make the path absolute, resolving all symlinks on the way and also normalizing it.
(self, strict=False)
| 979 | return self._from_parts([self.cwd()] + self._parts) |
| 980 | |
| 981 | def resolve(self, strict=False): |
| 982 | """ |
| 983 | Make the path absolute, resolving all symlinks on the way and also |
| 984 | normalizing it. |
| 985 | """ |
| 986 | |
| 987 | def check_eloop(e): |
| 988 | winerror = getattr(e, 'winerror', 0) |
| 989 | if e.errno == ELOOP or winerror == _WINERROR_CANT_RESOLVE_FILENAME: |
| 990 | raise RuntimeError("Symlink loop from %r" % e.filename) |
| 991 | |
| 992 | try: |
| 993 | s = os.path.realpath(self, strict=strict) |
| 994 | except OSError as e: |
| 995 | check_eloop(e) |
| 996 | raise |
| 997 | p = self._from_parts((s,)) |
| 998 | |
| 999 | # In non-strict mode, realpath() doesn't raise on symlink loops. |
| 1000 | # Ensure we get an exception by calling stat() |
| 1001 | if not strict: |
| 1002 | try: |
| 1003 | p.stat() |
| 1004 | except OSError as e: |
| 1005 | check_eloop(e) |
| 1006 | return p |
| 1007 | |
| 1008 | def stat(self, *, follow_symlinks=True): |
| 1009 | """ |
no test coverage detected