httk.core.register¶
Backward-compatible exports for registry implementations split by type.
Submodules¶
Attributes¶
Classes¶
Registry mapping keys -> plugin specs. |
|
Store registration metadata for one top-level httk command. |
|
Describe lazy typed handling for one exact entry-type definition IRI. |
Functions¶
|
Resolve a callable reference. |
|
Return command metadata without importing its implementation. |
|
Register a lazy top-level httk command. |
|
Return entry-family metadata without importing its class. |
|
Return record, family, and definition metadata without importing the record class. |
Return registered entry-family names. |
|
Return registered entry-provider names. |
|
|
Return registered record names, optionally limited to a family. |
Return registered entry-type definition IRIs without resolving imports. |
|
|
Return the exact-IRI binding without importing its backend or view. |
|
Register a lazy entry-family class reference without importing it. |
|
Register an |
|
Register a lazy record-class reference and optional family and definition IRI. |
|
Register one lazy typed binding, selected only by exact definition IRI. |
|
Import and return a registered entry-family class. |
|
Import and return a registered record class. |
|
Return whether |
Return the registered reader extensions. |
|
Return the registered reader basenames. |
|
Return format tags mapped to their registered adapter names. |
|
Return registered writer format tags. |
|
Return the registered writer extension and basename dispatch keys. |
|
|
Register one lazy adapter for each neutral payload format in |
|
Register one lazy serializer for a neutral payload format tag. |
|
Register a reader under one or more file |
|
Register a writer under one or more extensions and/or exact basenames. |
Return registered entry-type definition IRIs. |
|
Return registered property definition IRIs. |
|
|
Load and verify a registered entry-type definition resource. |
|
Load and verify a registered property definition resource. |
|
Register one resource for an entry-type definition IRI. |
|
Register one resource for a property definition IRI. |
Package Contents¶
- class httk.core.register.PluginRegistry[source]¶
Registry mapping keys -> plugin specs.
- Intended use:
readers: key is file extension “.cif”
savers: key is file extension “.cif” or format name
show/visualization: key is format/backend name
- httk.core.register.resolve_callable(ref)[source]¶
Resolve a callable reference.
- Accepts:
a callable object
a string of form “module.submodule:callable_name”
- class httk.core.register.CLICommand[source]¶
Store registration metadata for one top-level httk command.
- Parameters:
name – The lowercase hyphen-separated command name.
handler – The command callable or lazy reference.
summary – The one-line command summary.
- handler: str | collections.abc.Callable[Ellipsis, Any]¶
- httk.core.register.cli_command(name)[source]¶
Return command metadata without importing its implementation.
- Parameters:
name (str) – The command name to look up.
- Returns:
Command metadata, or
Noneif it is not registered.- Return type:
CLICommand | None
- httk.core.register.register_cli_command(name, handler, summary)[source]¶
Register a lazy top-level httk command.
A handler is either a callable or a lazy
"module:callable"reference with the contract(argv: Sequence[str], context: CLIContext) -> int. Names use lowercase, hyphen-separated command syntax. Registration is intentionally strict: reserved names and duplicate registrations are errors rather than order-dependent overrides.- Parameters:
name (str) – The lowercase hyphen-separated command name.
handler (str | collections.abc.Callable[Ellipsis, Any]) – The command callable or lazy
"module:callable"reference.summary (str) – The nonempty one-line command summary.
- Raises:
TypeError – If
handleris neither callable nor a lazy reference.ValueError – If the name, handler reference, summary, or registration is invalid.
- class httk.core.register.OptimadeEntryBinding[source]¶
Describe lazy typed handling for one exact entry-type definition IRI.
- Parameters:
name – The binding registry name.
definition_id – The exact entry-type definition IRI selected by the binding.
backend – The lazy backend class reference.
view – The lazy view class reference.
property_decoders – Property definition IRIs mapped to lazy decoder references.
query_fields – Property definition IRIs supported for querying, if restricted.
- property_decoders: collections.abc.Mapping[str, str]¶
- resolve_property_decoder(definition_id)[source]¶
Resolve one property decoder, or return
Nonewhen it is unbound.- Parameters:
definition_id (str) – The property definition IRI to resolve.
- Returns:
The decoder callable, or
Nonewhen no decoder is registered.- Return type:
collections.abc.Callable[Ellipsis, Any] | None
- httk.core.register.entry_family_info(name)[source]¶
Return entry-family metadata without importing its class.
- Parameters:
name (str) – The registered entry-family name.
- Returns:
The lazy family reference and optional definition IRI.
- Raises:
ValueError – If
nameis not registered.- Return type:
- httk.core.register.entry_record_info(name)[source]¶
Return record, family, and definition metadata without importing the record class.
- httk.core.register.known_entry_records(family=None)[source]¶
Return registered record names, optionally limited to a family.
- httk.core.register.known_optimade_entry_bindings()[source]¶
Return registered entry-type definition IRIs without resolving imports.
- httk.core.register.optimade_entry_binding(definition_id)[source]¶
Return the exact-IRI binding without importing its backend or view.
- Parameters:
definition_id (str) – The exact entry-type definition IRI to look up.
- Returns:
The binding, or
Noneif no exact match is registered.- Return type:
OptimadeEntryBinding | None
- httk.core.register.register_entry_family(*, name, family, definition_id=None)[source]¶
Register a lazy entry-family class reference without importing it.
- Parameters:
- Raises:
ValueError – If validation fails or
nameis already registered.
- httk.core.register.register_entry_provider(*, name, factory)[source]¶
Register an
EntryProviderfactory undername.factoryis a lazy"module:callable"reference to a callable that constructs a provider (providers need data, so applications call the factory themselves; the registry only records how to reach it). This mirrorsregister_reader.
- httk.core.register.register_entry_record(*, name, record, family=None, definition_id=None)[source]¶
Register a lazy record-class reference and optional family and definition IRI.
- Parameters:
- Raises:
ValueError – If validation fails or
nameis already registered.
- httk.core.register.register_optimade_entry_binding(*, name, definition_id, backend, view, property_decoders=None, query_fields=None)[source]¶
Register one lazy typed binding, selected only by exact definition IRI.
- Parameters:
name (str) – The binding registry name.
definition_id (str) – The exact entry-type definition IRI selected by the binding.
backend (str) – The lazy backend class reference.
view (str) – The lazy view class reference.
property_decoders (collections.abc.Mapping[str, str] | None) – Property definition IRIs mapped to lazy decoder references.
query_fields (tuple[str, Ellipsis] | None) – Property definition IRIs supported for querying, if restricted.
- Raises:
ValueError – If the definition IRI is already registered or input is invalid.
- httk.core.register.resolve_entry_family(name)[source]¶
Import and return a registered entry-family class.
- Parameters:
name (str) – The registered entry-family name.
- Returns:
The resolved entry-family class.
- Raises:
ValueError – If
nameis not registered.TypeError – If the reference does not resolve to a class.
- Return type:
- httk.core.register.resolve_entry_record(name)[source]¶
Import and return a registered record class.
- Parameters:
name (str) – The registered record name.
- Returns:
The resolved frozen dataclass record class.
- Raises:
ValueError – If
nameis not registered.TypeError – If the reference does not resolve to a frozen dataclass.
- Return type:
- httk.core.register.has_reader_for(name)[source]¶
Return whether
namematches a registered reader key.
- httk.core.register.known_format_adapters()[source]¶
Return format tags mapped to their registered adapter names.
- httk.core.register.known_writers()[source]¶
Return the registered writer extension and basename dispatch keys.
- httk.core.register.register_format_adapter(*, name, adapter, formats)[source]¶
Register one lazy adapter for each neutral payload format in
formats.adaptermay be a callable or a lazy"module:callable"reference. A format tag has one owner: registering it again raises an error naming both the existing and attempted registrants.- Parameters:
name (str) – The registry name for the adapter.
adapter (str | collections.abc.Callable[Ellipsis, Any]) – The adapter callable or lazy
"module:callable"reference.formats (collections.abc.Sequence[str]) – Neutral payload format tags served by the adapter.
- Raises:
ValueError – If a format tag is invalid, duplicated, or already owned.
- httk.core.register.register_format_serializer(*, format, serializer)[source]¶
Register one lazy serializer for a neutral payload format tag.
- Parameters:
format (str) – The neutral payload format tag.
serializer (str | collections.abc.Callable[Ellipsis, Any]) – The serializer callable or lazy reference.
- Raises:
ValueError – If
formatis invalid or already has another serializer.
- httk.core.register.register_reader(*, name, reader, extensions=(), filenames=())[source]¶
Register a reader under one or more file
extensionsand/orfilenames.extensionsare matched (case-insensitively) against a file’s suffix, e.g.".cif".filenamesare exact basenames matched (case-insensitively) against a file’s name with any recognized compression suffix stripped, e.g."POSCAR"matchesPOSCAR,poscar, andPOSCAR.bz2.
- httk.core.register.register_writer(*, name, writer, format, extensions=(), filenames=())[source]¶
Register a writer under one or more extensions and/or exact basenames.
A format can have one writer owner; registering a conflicting writer raises an error. Extension and basename keys are matched case-insensitively.
- Parameters:
name (str) – The registry name for the writer.
writer (str | collections.abc.Callable[Ellipsis, Any]) – The writer callable or lazy
"module:callable"reference.format (str) – The neutral payload format emitted by the writer.
extensions (tuple[str, Ellipsis]) – File suffixes that select the writer.
filenames (tuple[str, Ellipsis]) – Exact basenames that select the writer.
- Raises:
ValueError – If
formatis invalid or conflicts with an existing writer.
- httk.core.register.known_entry_type_definitions()[source]¶
Return registered entry-type definition IRIs.
- httk.core.register.known_property_definitions()[source]¶
Return registered property definition IRIs.
- httk.core.register.load_entry_type_definition(definition_id)[source]¶
Load and verify a registered entry-type definition resource.
- Parameters:
definition_id (str) – The registered entry-type definition IRI.
- Returns:
The loaded and validated entry-type definition.
- Raises:
ValueError – If the IRI is unregistered or disagrees with the document.
- Return type:
- httk.core.register.load_property_definition(definition_id)[source]¶
Load and verify a registered property definition resource.
- Parameters:
definition_id (str) – The registered property definition IRI.
- Returns:
The loaded and validated property definition.
- Raises:
ValueError – If the IRI is unregistered or disagrees with the document.
- Return type:
- httk.core.register.register_entry_type_definition(*, definition_id, resource)[source]¶
Register one resource for an entry-type definition IRI.
- Parameters:
- Raises:
ValueError – If
definition_idis already registered.
- httk.core.register.register_property_definition(*, definition_id, resource)[source]¶
Register one resource for a property definition IRI.
- Parameters:
- Raises:
ValueError – If
definition_idis already registered.