Python API Reference (fleetmesh_schema) ========================================= The `fleetmesh_schema` Python package carries the canonical schema documents and provides standard helper functions for resolving schema paths and loading JSON data with in-memory caching. Package API ----------- .. automodule:: fleetmesh_schema :members: :undoc-members: :show-inheritance: Functions & Constants Reference ------------------------------- - **``SCHEMA_DIR``**: Absolute filesystem path to the directory containing ``constants.json``, ``kinds.json``, ``messages.json``, and ``DIGEST``. - **``SCHEMAS_DIR``**: Absolute filesystem path to the directory containing JSON Schema Draft 2020-12 files (``common/``, ``events/``, etc.). - **``path(name: str) -> str``**: Computes the absolute path to a file under ``SCHEMA_DIR``. - **``schema_path(*parts: str) -> str``**: Computes the absolute path to a JSON Schema file under ``SCHEMAS_DIR``. - **``load_json(name: str) -> Any``**: Parses a JSON file from ``SCHEMA_DIR`` with automatic LRU memoization. Guarantees that every caller in the process receives the identical in-memory object without redundant disk I/O. - **``text(name: str) -> str``**: Reads and returns a text file from ``SCHEMA_DIR`` (e.g., ``DIGEST``, ``PROTOCOLS``) as a stripped string. - **``digest() -> str``**: Convenience accessor returning the active protocol version digest string from ``schema/DIGEST``. Usage Example ------------- .. code-block:: python import fleetmesh_schema # Inspect active protocol digest print("Active Digest:", fleetmesh_schema.digest()) # Load canonical event kinds dictionary kinds_data = fleetmesh_schema.load_json('kinds.json') print("Descriptor Kind:", kinds_data['kinds']['11801']['name']) # Locate a JSON Schema Draft 2020-12 file descriptor_schema = fleetmesh_schema.schema_path('events', 'kind-11801.json')