Return a new path from the given 'file' URI.
(cls, uri)
| 1468 | |
| 1469 | @classmethod |
| 1470 | def from_uri(cls, uri): |
| 1471 | """Return a new path from the given 'file' URI.""" |
| 1472 | from urllib.error import URLError |
| 1473 | from urllib.request import url2pathname |
| 1474 | try: |
| 1475 | path = cls(url2pathname(uri, require_scheme=True)) |
| 1476 | except URLError as exc: |
| 1477 | raise ValueError(exc.reason) from None |
| 1478 | if not path.is_absolute(): |
| 1479 | raise ValueError(f"URI is not absolute: {uri!r}") |
| 1480 | return path |
| 1481 | |
| 1482 | |
| 1483 | class PosixPath(Path, PurePosixPath): |