-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
26 lines (20 loc) · 1.01 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import glob
import importlib.util
import os
extension_folder = os.path.dirname(os.path.realpath(__file__))
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
pyPath = os.path.join(extension_folder, 'nodes')
def loadCustomNodes():
files = glob.glob(os.path.join(pyPath, "*Node.py"), recursive=True)
for file in files:
file_relative_path = file[len(extension_folder):]
model_name = file_relative_path.replace(os.sep, '.')
model_name = os.path.splitext(model_name)[0]
module = importlib.import_module(model_name, __name__)
if hasattr(module, "NODE_CLASS_MAPPINGS") and getattr(module, "NODE_CLASS_MAPPINGS") is not None:
NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS)
if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS") and getattr(module, "NODE_DISPLAY_NAME_MAPPINGS") is not None:
NODE_DISPLAY_NAME_MAPPINGS.update(module.NODE_DISPLAY_NAME_MAPPINGS)
loadCustomNodes()
__all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS']