Files
MyFastHtml/src/myfasthtml/core/instances_helper.py
2025-11-16 23:06:00 +01:00

27 lines
1.2 KiB
Python

import logging
from myfasthtml.controls.CommandsDebugger import CommandsDebugger
from myfasthtml.controls.InstancesDebugger import InstancesDebugger
from myfasthtml.controls.VisNetwork import VisNetwork
from myfasthtml.controls.helpers import Ids
from myfasthtml.core.instances import BaseInstance, InstancesManager
logger = logging.getLogger("InstancesHelper")
class InstancesHelper:
@staticmethod
def dynamic_get(parent: BaseInstance, component_type: str, instance_id: str):
if component_type == Ids.VisNetwork:
return InstancesManager.get(parent.get_session(), instance_id,
VisNetwork, parent=parent, _id=instance_id)
elif component_type == Ids.InstancesDebugger:
return InstancesManager.get(parent.get_session(), instance_id,
InstancesDebugger, parent.get_session(), parent, instance_id)
elif component_type == Ids.CommandsDebugger:
return InstancesManager.get(parent.get_session(), instance_id,
CommandsDebugger, parent.get_session(), parent, instance_id)
logger.warning(f"Unknown component type: {component_type}")
return None