mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-30 01:16:33 +02:00
[core] add optional 'name' argument to addNewNode method
allow to create a new node with a target name, that will get prefixed if not unique
This commit is contained in:
parent
474e18ef4c
commit
d2417e4ac6
1 changed files with 12 additions and 7 deletions
|
@ -1128,16 +1128,21 @@ class Graph(BaseObject):
|
||||||
|
|
||||||
return inEdges, outEdges
|
return inEdges, outEdges
|
||||||
|
|
||||||
@Slot(str, result=Node)
|
def addNewNode(self, nodeDesc, name=None, **kwargs):
|
||||||
def addNewNode(self, nodeType, **kwargs):
|
|
||||||
"""
|
"""
|
||||||
|
Create and add a new node to the graph.
|
||||||
|
|
||||||
:param nodeType:
|
Args:
|
||||||
:param kwargs:
|
nodeDesc (desc.Node): the node description to use.
|
||||||
:return:
|
name (str): if specified, the desired name for this node. If not unique, will be prefixed (_N).
|
||||||
:rtype: Node
|
**kwargs: keyword arguments to initialize node's attributes
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
The newly created node.
|
||||||
"""
|
"""
|
||||||
n = self.addNode(Node(nodeDesc=nodeType, **kwargs))
|
if name and name in self._nodes.keys():
|
||||||
|
name = self._createUniqueNodeName(name)
|
||||||
|
n = self.addNode(Node(nodeDesc=nodeDesc, **kwargs), uniqueName=name)
|
||||||
n.updateInternals()
|
n.updateInternals()
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue