#NEWLINE# def add( self , tool , _job = None ) : #NEWLINE# #INDENT# 'Add a tool or a node to the pipeline. If the given value\n        is not a node, it is wrapped in a new node instance and then added\n        to the pipeline. The newly created node is returned.\n\n        Note that the nodes uniquely map to tool instances. You can not\n        add the same instance twice to the pipeline. Instead, no new\n        node will be added and the already existing node will be returned.\n\n        :param tool: the tool or node\n        :type tool: :class:`jip.tools.Tool` or :class:`Node`\n        :returns: the new node\n        :rtype: :class:`Node`\n        ' #NEWLINE# if isinstance ( tool , Node ) : #NEWLINE# #INDENT# n = tool #NEWLINE# self . _nodes [ n . _tool ] = n #NEWLINE# n . _pipeline = ( self . _name if self . _name else n . _pipeline ) #NEWLINE# n . _graph = self #NEWLINE# n . _job . _pipeline = self #NEWLINE# n . _node_index = self . _node_index #NEWLINE# self . _node_index += 1 #NEWLINE# name = n . _tool . name #NEWLINE# if n . _job . name : #NEWLINE# #INDENT# name = n . _job . name #NEWLINE# #UNINDENT# log . debug ( 'Add node | added %s' , tool ) #NEWLINE# self . _apply_node_name ( n , name ) #NEWLINE# return n #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( tool in self . _nodes ) ) : #NEWLINE# #INDENT# n = Node ( tool , self ) #NEWLINE# if ( ( not _job ) and tool . _job ) : #NEWLINE# #INDENT# _job = Job . from_profile ( tool . _job , self ) #NEWLINE# #UNINDENT# job = ( _job ( ) if _job else self . _current_job ( ) ) #NEWLINE# n . _tool . _job = job #NEWLINE# n . _pipeline = self . _name #NEWLINE# n . _pipeline_name = self . _pipeline_name #NEWLINE# n . _job = job #NEWLINE# job . _node = n #NEWLINE# self . _nodes [ tool ] = n #NEWLINE# n . _node_index = self . _node_index #NEWLINE# self . _node_index += 1 #NEWLINE# name = ( tool . name if ( not job . name ) else job . name ) #NEWLINE# log . debug ( 'Add node | added %s' , name ) #NEWLINE# self . _apply_node_name ( n , name ) #NEWLINE# n . _pipeline_profile = ( _job ( ) if _job else self . _current_job ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# return self . _nodes [ tool ]