-
Notifications
You must be signed in to change notification settings - Fork 135
/
node.py
25 lines (18 loc) · 843 Bytes
/
node.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
class Node:
def __init__(self, node):
self.node = node
def type(self):
return self.node["class_type"]
def is_type(self, type):
return "class_type" in self.node and self.node["class_type"] == type
def is_type_in(self, types):
return "class_type" in self.node and self.node["class_type"] in types
def has_input(self, key):
return key in self.node["inputs"]
def input(self, key, default_value=None):
return self.node["inputs"][key] if key in self.node["inputs"] else default_value
def set_input(self, key, value):
self.node["inputs"][key] = value
def raise_if_unsupported(self, unsupported_nodes={}):
if self.is_type_in(unsupported_nodes):
raise ValueError(f"{self.type()} node is not supported: {unsupported_nodes[self.type()]}")