mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-30 17:36:33 +02:00
[core] expose registerNodeType function
This commit is contained in:
parent
b95e96449b
commit
7da2466c74
1 changed files with 14 additions and 4 deletions
|
@ -67,15 +67,25 @@ def loadNodes(folder, packageName):
|
|||
return nodeTypes
|
||||
|
||||
|
||||
def registerNodeType(nodeType):
|
||||
""" Register a Node Type based on a Node Description class.
|
||||
|
||||
After registration, nodes of this type can be instantiated in a Graph.
|
||||
"""
|
||||
global nodesDesc
|
||||
if nodeType.__name__ in nodesDesc:
|
||||
raise RuntimeError("Node Desc {} is already registered.".format(nodeType.__name__))
|
||||
nodesDesc[nodeType.__name__] = nodeType
|
||||
|
||||
|
||||
def loadAllNodes(folder):
|
||||
global nodesDesc
|
||||
for f in os.listdir(folder):
|
||||
if os.path.isdir(os.path.join(folder, f)) and not f.startswith('__'):
|
||||
nodeTypes = loadNodes(folder, f)
|
||||
|
||||
nodes = dict([(m.__name__, m) for m in nodeTypes])
|
||||
print('Plugins loaded: ', ', '.join(nodes.keys()))
|
||||
nodesDesc.update(nodes)
|
||||
for nodeType in nodeTypes:
|
||||
registerNodeType(nodeType)
|
||||
print('Plugins loaded: ', ', '.join([nodeType.__name__ for nodeType in nodeTypes]))
|
||||
|
||||
|
||||
# Load plugins
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue