saturnin.component.apps¶
Saturnin application registration and discovery.
This module handles the registration and discovery of Saturnin applications.
Applications are registered as entry points where EntryPoint.load() is
expected to return an instance of ApplicationDescriptor. The default
entry point group for application registration is saturnin.application.
It provides ApplicationInfo to represent application metadata and
ApplicationRegistry to manage these applications.
Globals¶
- saturnin.component.apps.application_registry: ApplicationRegistry¶
Global
ApplicationRegistryinstance, automatically populated by load() upon module import.
Classes¶
- class saturnin.component.apps.ApplicationInfo(*, uid: UUID, name: str, version: str, vendor: UUID, classification: str, description: str, descriptor: str, distribution: str, cli_command: str | None = None, recipe_factory: str | None = None)[source]¶
Bases:
DistinctInformation about application stored in
ApplicationRegistry.- Parameters:
uid (UUID) – Application UID
name (str) – Application name
version (str) – Application version
vendor (UUID) – Application vendor UID
classification (str) – Application classification
description (str) – Application description
cli_command (str | None) – Application factory specification (entry point)
recipe_factory (str | None) – Application configuration factory (entry point)
descriptor (str) – Application descriptor specification (entry point)
distribution (str) – Installed distribution package that contains this application
- as_toml_dict() dict[source]¶
Returns dictionary with instance data suitable for storage in TOML format (values that are not of basic type are converted to string).
- Return type:
- get_key() Hashable[source]¶
Returns the application UID, which serves as its unique key.
- Return type:
- get_recipe_name() str[source]¶
Returns default recipe name for this application. If application name contains dots, only part after last dot is returned. Otherwise it returns the application name.
- Return type:
- is_command() bool[source]¶
Returns tru if application is console command.
Such applications are not installed via recipe, but directly into console.
- Return type:
- property cli_command_obj: Callable[[...], Any]¶
Application command factory object. If it’s not assigned directly, then it’s loaded using
factoryon first access.
- property descriptor_obj: ApplicationDescriptor¶
Application descriptor object. If it’s not assigned directly, then it’s loaded using
descriptoron first access.
- property recipe_factory_obj: Callable[[], str]¶
Application configuration factory object. If it’s not assigned directly, then it’s loaded using
configon first access.
- property set_cli_command_obj: Callable[[...], Any]¶
Application command factory object. If it’s not assigned directly, then it’s loaded using
factoryon first access.
- property set_descriptor_obj: ApplicationDescriptor¶
Application descriptor object. If it’s not assigned directly, then it’s loaded using
descriptoron first access.
- class saturnin.component.apps.ApplicationRegistry(data: Mapping[Any, Distinct] | Sequence[Distinct] | Registry = None)[source]¶
Bases:
RegistrySaturnin application registry.
Holds
ApplicationInfoinstances.It is used in two modes:
In a full Saturnin deployment, information about applications is loaded from a TOML file. Application descriptors and factories are then loaded on demand.
In standalone service/bundle mode, application information, including application descriptors and factories, is stored directly by the executor script. This allows for scenarios where dynamic discovery is not used, and the application can be compiled (e.g., with Nuitka).
- Parameters:
data (Mapping[Any, Distinct] | Sequence[Distinct] | Registry)
- add(descriptor: ApplicationDescriptor, factory: Any, distribution: str) None[source]¶
Direct application registration. Used by systems that do not allow dynamic discovery, for example programs compiled by Nuitka.
- Parameters:
descriptor (ApplicationDescriptor) – Application descriptor
factory (Any) – Application factory
distribution (str) – Distribution package name with application
- Return type:
None
- load() None[source]¶
Reads information about installed applications from a previously saved TOML file, located at
directory_scheme.site_apps_toml, if it exists.- Return type:
None
- load_from_installed(*, ignore_errors: bool = False) None[source]¶
Populate registry from descriptors of installed applications.
- Parameters:
ignore_errors (bool) – When True, errors are ignored, otherwise
Erroris raised.- Return type:
None