# Master init for artyclaw-comfy import importlib import os NODE_CLASS_MAPPINGS = {} NODE_DISPLAY_NAME_MAPPINGS = {} # Path to the 'py' subfolder py_dir = os.path.join(os.path.dirname(__file__), "py") # Dynamically scan and import all nodes in the py/ folder for filename in os.listdir(py_dir): if filename.endswith(".py") and not filename.startswith("__"): module_name = filename[:-3] try: # Safely import the module relatively (e.g., from .py import my_node) module = importlib.import_module(f".py.{module_name}", package=__name__) if hasattr(module, "NODE_CLASS_MAPPINGS"): NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS) if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS"): NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS) except Exception as e: print(f"[artyclaw-comfy] Failed to load {module_name}: {e}") __all__ =["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"] print(f"[artyclaw-comfy] Loaded {len(NODE_CLASS_MAPPINGS)} custom nodes successfully.")