@@ -23,17 +23,17 @@ def __init__(self):
2323 def buildNode (self ):
2424 obj = self .get_property ('self' )
2525 if obj :
26- self .set_name (obj .__class__ .__name__ .capitalize ())
26+ self .set_name ('Object Wrapper (%s)' % obj .__class__ .__name__ .capitalize ())
2727 else :
2828 self .set_name ('Object Wrapper (None)' )
2929
30- # switch math function type
3130 if 'methods' not in self .view .widgets :
3231 self .add_combo_menu ('methods' ,
3332 'Methods' ,
3433 items = dir (obj ),
3534 tab = 'widgets' )
3635
36+ self .funcName = self .view .widgets ['methods' ].widget .currentText ()
3737 self .view .widgets ['methods' ].value_changed .connect (
3838 self .addFunction )
3939 self .view .widgets ['methods' ].value_changed .connect (
@@ -52,8 +52,9 @@ def addFunction(self, prop, func):
5252 self .funcName = func
5353 obj = self .get_property ('self' )
5454 func = getattr (obj , self .funcName )
55- dataFunc = inspect .signature (func )
56-
55+
56+ if callable (func ):
57+ dataFunc = inspect .getfullargspec (func )
5758 for arg in dataFunc .args :
5859 if not self .has_property (arg ):
5960 inPort = self .add_input (arg )
@@ -65,6 +66,10 @@ def addFunction(self, prop, func):
6566 inPort .set_visible (True )
6667 else :
6768 inPort .set_visible (False )
69+ else :
70+ for inPort in self ._inputs :
71+ if inPort .name () != 'self' :
72+ inPort .set_visible (False )
6873
6974 def getSelf (self ):
7075 for from_port in self .selfPort .connected_ports ():
@@ -100,10 +105,10 @@ def run(self):
100105
101106 try :
102107 # Execute math function with arguments.
103- data = self .func ( * [
104- self .get_property (inport .name ()) for inport in self ._inputs
105- if inport . visible () and inport . name () != 'self'
106- ])
108+ if callable ( self .func ):
109+ data = self .func ( * [ self . get_property (inport .name ()) for inport in self ._inputs if inport . visible () and inport . name () != 'self' ])
110+ else :
111+ data = self . func
107112
108113 self .set_property ('output' , data )
109114 except KeyError as error :
@@ -128,3 +133,25 @@ def on_input_disconnected(self, to_port, from_port):
128133 comboBox = self .view .widgets ['methods' ].widget
129134 comboBox .clear ()
130135 self .update_streams ()
136+
137+
138+ class SelfNode (BaseNode ):
139+ """
140+ A node class with 3 inputs and 3 outputs.
141+ The last input and last output can take in multiple pipes.
142+ """
143+
144+ # unique node identifier.
145+ __identifier__ = 'Util'
146+
147+ # initial default node name.
148+ NODE_NAME = 'MetaNode'
149+
150+ def __init__ (self ):
151+ super (SelfNode , self ).__init__ ()
152+ self .add_output ('self' )
153+ self .create_property ('self' , None )
154+
155+ def run (self ):
156+ self .set_property ('self' , self )
157+
0 commit comments