topmark.registry.identity¶
Identity helpers for the TopMark registry.
This module centralizes small, dependency-light helpers related to registry identity construction and validation. It is intentionally shared by both file-type and processor models so namespace/local-key rules remain consistent.
owner_label ¶
Return a stable fully-qualified owner label for a Python type.
This helper is used in registry identity validation and error reporting to identify the defining class in a consistent diagnostic form.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_type
|
type[object]
|
The class/type to label. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Fully-qualified owner label for diagnostics and validation messages. |
Source code in src/topmark/registry/identity.py
make_qualified_key ¶
Build a canonical qualified key from a namespace and local key.
Format: "
This helper centralizes identity construction for registry entities such as FileType and HeaderProcessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
Namespace identifier (must already be validated). |
required |
local_key
|
str
|
Namespace-local identifier. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Fully-qualified key string. |
Note
This function does not perform validation. Callers are expected to provide already validated tokens.
Source code in src/topmark/registry/identity.py
split_qualified_key ¶
Split "<namespace>:<local_key>" into its components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qualified_key
|
str
|
Fully-qualified registry identifier. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
|
Notes
This helper performs a lightweight split only. It does not validate the resulting tokens or reject malformed inputs with multiple separators.
Source code in src/topmark/registry/identity.py
is_valid_registry_token ¶
Return whether a registry token is valid.
Valid tokens are lowercase, must not contain ":", and must match
VALID_REGISTRY_TOKEN_RE.
Source code in src/topmark/registry/identity.py
validate_registry_token ¶
Validate a single registry token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Token value to validate. |
required |
field_name
|
str
|
Name of the corresponding field (for error reporting). |
required |
owner
|
str
|
Fully-qualified owner label (for error reporting). |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If validation fails. |
Source code in src/topmark/registry/identity.py
require_nonempty_str ¶
Return value as str after enforcing type and non-empty presence.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
Candidate value to validate. |
required |
field_name
|
str
|
Name of the corresponding field (for error reporting). |
required |
owner
|
str
|
Fully-qualified owner label (for error reporting). |
required |
Returns:
| Type | Description |
|---|---|
str
|
The validated string value. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in src/topmark/registry/identity.py
require_and_validate_registry_identity ¶
Validate and normalize a registry identity pair.
This helper first enforces that both values are non-empty strings and then validates them as registry tokens.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
object
|
Candidate namespace value. |
required |
local_key
|
object
|
Candidate namespace-local identifier. |
required |
owner
|
str
|
Fully-qualified owner label (for error reporting). |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
Normalized |
Raises:
| Type | Description |
|---|---|
TypeError
|
If either value is missing, not a string, or fails token validation. |
Source code in src/topmark/registry/identity.py
validate_registry_identity ¶
Validate a registry identity pair (namespace, local_key).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
Namespace value to validate. |
required |
local_key
|
str
|
Namespace-local identifier to validate. |
required |
owner
|
str
|
Fully-qualified owner label (for error reporting). |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If either token fails validation. |
Source code in src/topmark/registry/identity.py
validate_reserved_topmark_namespace ¶
Validate reserved use of the built-in topmark namespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
namespace
|
str
|
Namespace value to validate. |
required |
owner
|
str
|
Fully-qualified owner label (for error reporting). |
required |
owner_module
|
str
|
Defining module of the corresponding entity. |
required |
entities
|
str
|
Human label for the validated entity type (for example,
|
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the reserved TopMark namespace is used outside the TopMark package. |