refactor: improve __init__.py a bit

This commit is contained in:
Drac
2025-06-16 19:40:59 +02:00
parent 7d18bf06b3
commit 65e9cd6638
+9 -5
View File
@@ -1,4 +1,6 @@
import importlib
import logging
import os
from .pyserver import (
get_key_from_jssetting, # noqa: F401
@@ -23,13 +25,15 @@ NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
for module_name in node_list:
imported_module = importlib.import_module(f".nodes.{module_name}", __name__)
NODE_CLASS_MAPPINGS = {**NODE_CLASS_MAPPINGS, **imported_module.NODE_CLASS_MAPPINGS}
NODE_DISPLAY_NAME_MAPPINGS = {**NODE_DISPLAY_NAME_MAPPINGS, **imported_module.NODE_DISPLAY_NAME_MAPPINGS}
try:
imported_module = importlib.import_module(f".nodes.{module_name}", __name__)
NODE_CLASS_MAPPINGS.update(imported_module.NODE_CLASS_MAPPINGS)
NODE_DISPLAY_NAME_MAPPINGS.update(imported_module.NODE_DISPLAY_NAME_MAPPINGS)
except ImportError as e:
logging.warning(f"Could not import module '{module_name}': {e}")
WEB_DIRECTORY = "./js"
WEB_DIRECTORY = os.path.join(os.path.dirname(__file__), "js")
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]