Files

38 lines
1.2 KiB
Python

import importlib.util
from pathlib import Path
def _load_local_nodes():
nodes_path = Path(__file__).with_name("nodes.py")
spec = importlib.util.spec_from_file_location(
"comfyui_whisper_large_v3_repack_nodes",
nodes_path,
)
if spec is None or spec.loader is None:
raise ImportError(f"Unable to load {nodes_path}")
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
try:
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
except (ImportError, SystemError, ValueError) as exc:
try:
_nodes = _load_local_nodes()
except ModuleNotFoundError as fallback_exc:
if fallback_exc.name != "folder_paths":
raise
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
except ImportError:
if "folder_paths" not in str(exc):
raise
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
else:
NODE_CLASS_MAPPINGS = _nodes.NODE_CLASS_MAPPINGS
NODE_DISPLAY_NAME_MAPPINGS = _nodes.NODE_DISPLAY_NAME_MAPPINGS
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]