sybaritic.uri
SPARTAN_DEFAULT_PORT
module-attribute
The default TCP network port for the Spartan protocol.
SPARTAN_PREFIX
module-attribute
SPARTAN_PREFIX: Final[str] = f'{SPARTAN_SCHEME}://'
The standard prefix for Spartan URIs.
SPARTAN_SCHEME
module-attribute
The default URL scheme for the Spartan protocol.
SpartanURI
SpartanURI(
uri: str | SpartanURI,
*,
host: str | None = None,
port: int | None = None,
path: str | None = None,
scheme: str | None = None,
)
Represents a validated Spartan protocol URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | SpartanURI
|
The raw URI string or an existing SpartanURI to clone. |
required |
|
str | None
|
Optional host override. |
None
|
|
int | None
|
Optional port override. |
None
|
|
str | None
|
Optional path override. |
None
|
|
str | None
|
Optional scheme override. |
None
|
Raises:
| Type | Description |
|---|---|
URIError
|
If the URI is empty, scheme is missing or not 'spartan', host is missing, or URI parsing fails. |
netloc
property
netloc: str
Return the network location portion ('host' or 'host:port' if non-default).
parent
property
parent: SpartanURI
Return a new SpartanURI pointing to the parent directory path without query.
without_query
property
without_query: SpartanURI
Return a new SpartanURI with any query string removed.
parse
classmethod
parse(uri_str: str | SpartanURI) -> SpartanURI
Parse a URI string or return a SpartanURI instance.
replace
replace(
*,
host: str | _UnsetType = _UNSET,
port: int | _UnsetType = _UNSET,
path: str | _UnsetType = _UNSET,
query: str | None | _UnsetType = _UNSET,
) -> SpartanURI
Return a new SpartanURI with specified fields replaced.
resolve_redirect
resolve_redirect(target_path: str) -> SpartanURI
Return a new SpartanURI for a redirect target on the same host.
with_default_scheme
classmethod
with_default_scheme(uri_str: str) -> SpartanURI
Construct a SpartanURI from a string, prepending 'spartan://' if missing.
with_query
with_query(query: str | None) -> SpartanURI
Return a new SpartanURI with the specified query string (or None to clear).