All four name-dispatch factories repeated the same if/elif lazy-import pattern. Replace with a ComponentFactory base class holding a callable registry and a _lazy() helper for the common import-and-construct case. PlantFactory is an orchestrator, not a dispatcher, and is left as-is. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tqxrk8uj4M3w3d3eXm3xK8
14 lines
330 B
Python
14 lines
330 B
Python
from components.factory import ComponentFactory, _lazy
|
|
|
|
|
|
def _sim(dt, params):
|
|
from components.actor.stirrersim import StirrerSim
|
|
return StirrerSim(dt)
|
|
|
|
|
|
class StirrerFactory(ComponentFactory):
|
|
_registry = {
|
|
"sim": _sim,
|
|
"1376": _lazy("components.actor.stirrerpololu1376", "StirrerPololu1376"),
|
|
}
|