port79.uri
Finger URI representation and parsing based on RFC 1288.
FINGER_DEFAULT_PORT
module-attribute
The default TCP network port for the Finger protocol.
FINGER_PREFIX
module-attribute
FINGER_PREFIX: Final[str] = f'{FINGER_SCHEME}://'
The standard prefix for Finger URIs.
FINGER_SCHEME
module-attribute
The default URL scheme for the Finger protocol.
FingerURI
Represents a validated Finger protocol URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | FingerURI
|
The raw URI string, query string, or an existing FingerURI to clone. |
required |
Raises:
| Type | Description |
|---|---|
URIError
|
If the URI is empty, the host is missing or invalid, or if parsing of the URI fails. |
MAXIMUM_LENGTH
class-attribute
instance-attribute
The maximum length of a Finger URI string.
bytes_left
cached
property
bytes_left: int
The number of characters remaining before reaching maximum URI length.
is_forwarding_query
property
is_forwarding_query: bool
Whether this query involves remote host forwarding.
is_system_query
property
is_system_query: bool
Whether this is a system-wide query for logged-in users.
is_too_long
cached
property
is_too_long: bool
Whether the URI string length exceeds the maximum allowed length.
query_kind
property
query_kind: QueryKind
The QueryKind enumeration value representing this query type.
target_host
property
target_host: str | None
The remote target host for forwarding queries, if applicable.
from_string
classmethod
Create a FingerURI from a target string or URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The target string (e.g., 'davep@plan.cat' or 'finger://plan.cat/davep'). |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new FingerURI instance. |
Raises:
| Type | Description |
|---|---|
URIError
|
If parsing fails or required host is missing. |
replace
replace(
*,
host: str | _UnsetType = _UNSET,
port: int | _UnsetType = _UNSET,
username: str | None | _UnsetType = _UNSET,
target_host: str | None | _UnsetType = _UNSET,
is_verbose: bool | _UnsetType = _UNSET,
path: str | None | _UnsetType = _UNSET,
query: str | None | _UnsetType = _UNSET,
) -> Self
Create a new FingerURI by replacing specific parts of this URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str | _UnsetType
|
The new hostname, or _UNSET to keep current host. |
_UNSET
|
|
int | _UnsetType
|
The new port number, or _UNSET to keep current port. |
_UNSET
|
|
str | None | _UnsetType
|
The new username, None to clear, or _UNSET to keep current. |
_UNSET
|
|
str | None | _UnsetType
|
The new target host for forwarding, None to clear, or _UNSET. |
_UNSET
|
|
bool | _UnsetType
|
The new verbose status, or _UNSET to keep current. |
_UNSET
|
|
str | None | _UnsetType
|
The new path, or _UNSET to derive from username/verbose. |
_UNSET
|
|
str | None | _UnsetType
|
The new query string, or _UNSET to derive from verbose. |
_UNSET
|
Returns:
| Type | Description |
|---|---|
Self
|
A new FingerURI instance with updated components. |
Raises:
| Type | Description |
|---|---|
URIError
|
If the resulting URI components are invalid. |
with_default_scheme
classmethod
Add the Finger scheme to a URI if it is missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The URI string to check and potentially modify. |
required |
Returns:
| Type | Description |
|---|---|
Self
|
A new FingerURI instance with the scheme added if missing. |
Raises:
| Type | Description |
|---|---|
URIError
|
If the URI is invalid or missing required components. |