Return a new path from the given 'file' URI.
(cls, uri)
| 1270 | |
| 1271 | @classmethod |
| 1272 | def from_uri(cls, uri): |
| 1273 | """Return a new path from the given 'file' URI.""" |
| 1274 | from urllib.error import URLError |
| 1275 | from urllib.request import url2pathname |
| 1276 | try: |
| 1277 | path = cls(url2pathname(uri, require_scheme=True)) |
| 1278 | except URLError as exc: |
| 1279 | raise ValueError(exc.reason) from None |
| 1280 | if not path.is_absolute(): |
| 1281 | raise ValueError(f"URI is not absolute: {uri!r}") |
| 1282 | return path |
| 1283 | |
| 1284 | |
| 1285 | class PosixPath(Path, PurePosixPath): |