gcode_reader.emulate.registry¶
Dynamic registry for Machine subclasses.
Machines self-register via the 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 load_entry_points() once
(e.g. in gcode_reader/__init__.py) to pull in installed third-party machines.
Functions¶
|
Return the Machine subclass registered under name. |
|
Return a copy of the full registry mapping (names + aliases -> classes). |
|
Discover and import third-party machines registered via entry points. |
|
Class decorator that registers a Machine subclass by name. |
Module Contents¶
- gcode_reader.emulate.registry.get(name: str) type[gcode_reader.emulate.machine.Machine][source]¶
Return the Machine subclass registered under name.
- Parameters:
name – Key or alias (case-insensitive, spaces and underscores ignored).
- Raises:
ValueError – If name is not found in the registry.
- gcode_reader.emulate.registry.list_machines() dict[str, type[gcode_reader.emulate.machine.Machine]][source]¶
Return a copy of the full registry mapping (names + aliases -> classes).
- gcode_reader.emulate.registry.load_entry_points() None[source]¶
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.
- gcode_reader.emulate.registry.register(name: str, aliases: list[str] | None = None)[source]¶
Class decorator that registers a Machine subclass by name.
- Parameters:
name – Primary key used to look up the machine.
aliases – Optional additional keys that resolve to the same class.
Example:
@register("acme", aliases=["acme_v2"]) class AcmePrinter(Machine): ...