gcode_reader.emulate.registry ============================= .. py:module:: gcode_reader.emulate.registry .. autoapi-nested-parse:: Dynamic registry for Machine subclasses. Machines self-register via the :func:`register` decorator. Third-party packages can add new machine types by applying the same decorator and advertising the class through the ``gcode_reader.machines`` entry-point group in their ``pyproject.toml``:: [project.entry-points."gcode_reader.machines"] acme = "acme_gcode:AcmePrinter" The registry is populated at import time; call :func:`load_entry_points` once (e.g. in ``gcode_reader/__init__.py``) to pull in installed third-party machines. Functions --------- .. autoapisummary:: gcode_reader.emulate.registry.get gcode_reader.emulate.registry.list_machines gcode_reader.emulate.registry.load_entry_points gcode_reader.emulate.registry.register Module Contents --------------- .. py:function:: get(name: str) -> type[gcode_reader.emulate.machine.Machine] Return the Machine subclass registered under *name*. :param name: Key or alias (case-insensitive, spaces and underscores ignored). :raises ValueError: If *name* is not found in the registry. .. py:function:: list_machines() -> dict[str, type[gcode_reader.emulate.machine.Machine]] Return a copy of the full registry mapping (names + aliases -> classes). .. py:function:: load_entry_points() -> None Discover and import third-party machines registered via entry points. Call this once at package initialisation to pick up machines shipped by external packages. Safe to call multiple times. .. py:function:: register(name: str, aliases: list[str] | None = None) Class decorator that registers a Machine subclass by name. :param name: Primary key used to look up the machine. :param aliases: Optional additional keys that resolve to the same class. Example:: @register("acme", aliases=["acme_v2"]) class AcmePrinter(Machine): ...