URI & Schemes API
pathlib_next.uri
Uri(*uris, **options)
Bases: Pathname
A pure (no I/O) RFC 3986 URI, lazily parsed into source (scheme/
userinfo/host/port), path, query, and fragment on first access.
Join semantics (multiple constructor args, or /) are pathlib-
joinpath-like, not RFC 3986 reference resolution -- see
_load_parts's docstring and docs/divergences.md.
Source code in src/pathlib_next/uri/__init__.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
normalized_path
property
Return the normalized path using posixpath rules.
parent
property
The logical parent of the path.
parts
property
The tuple of URI components: (source, path, query, fragment).
__str__()
Return the string representation of the path, suitable for passing to system calls.
Source code in src/pathlib_next/uri/__init__.py
254 255 256 257 | |
is_absolute()
True if the path is absolute.
Source code in src/pathlib_next/uri/__init__.py
406 407 408 | |
is_local()
Return True if the URI points to a local resource.
Source code in src/pathlib_next/uri/__init__.py
452 453 454 | |
is_relative_to(other)
Return True if the path is relative to another path or False.
Source code in src/pathlib_next/uri/__init__.py
410 411 412 413 414 415 416 417 418 419 420 421 422 | |
with_fragment(fragment)
Return a new URI with the fragment replaced.
Source code in src/pathlib_next/uri/__init__.py
356 357 358 | |
with_path(path)
Return a new URI with the path replaced.
Source code in src/pathlib_next/uri/__init__.py
341 342 343 344 345 346 347 348 | |
with_query(query)
Return a new URI with the query replaced.
Source code in src/pathlib_next/uri/__init__.py
350 351 352 353 354 | |
with_segments(*segments)
Return a new URI with the path segments replaced.
Source code in src/pathlib_next/uri/__init__.py
335 336 337 338 339 | |
with_source(source)
Return a new URI with the source replaced.
Source code in src/pathlib_next/uri/__init__.py
331 332 333 | |
UriPath(*uris, **options)
Uri + Path (I/O) + scheme dispatch. UriPath(...) constructs
the concrete subclass registered for the URI's scheme (via __SCHEMES)
-- e.g. UriPath("http://...") returns an HttpPath. Subclass this
and set __SCHEMES to add a new scheme (Track B of extending this
library; see docs/guides/extending.md); implement the I/O surface
(_listdir or _scandir, stat, _open, ...) documented in
docs/guides/extending.md. Prefer overriding _scandir() over _listdir() when the
listing call already returns type/size/mtime metadata (PROPFIND, MLSD,
listdir_attr, an S3 list page, ...) -- walk()/glob() then answer
is_dir() on the results for free, without a stat request per entry.
Source code in src/pathlib_next/uri/__init__.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
backend
property
The connection or session state backend instance.
with_backend(backend)
Return a new path instance sharing the same backend state.
Source code in src/pathlib_next/uri/__init__.py
639 640 641 | |
pathlib_next.uri.source
Source
Bases: NamedTuple
A URI's scheme/userinfo/host/port -- everything before the path.
Falsy (bool(source) is False) when every field is empty/None.
is_local()
cached
Whether host resolves to this machine.
Caches per unique Source (Source is an immutable value type), since this does a DNS lookup (socket.gethostbyname) -- never call it on a hot path uncached.
Source code in src/pathlib_next/uri/source.py
256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
pathlib_next.uri.query
Query
Bases: str
A URI query string (str subclass) that can also be built from a
dict/list of pairs and decoded back with to_dict()/iteration.