MCPcopy Create free account
hub / github.com/ImageEngine/cortex / __opSmartOperator

Function __opSmartOperator

python/IECore/OpOverwriting.py:41–60  ·  view source on GitHub ↗

Smart version of Op.operator function. It accepts python values, simple structures and Data objects as values for the Op parameters. It also accepts a single IECore.CompoundObject parameter that is forwarded to the operate method as the values for all the Op parameters.

( self, *cargs, **args )

Source from the content-addressed store, hash-verified

39"""
40
41def __opSmartOperator( self, *cargs, **args ):
42 """
43 Smart version of Op.operator function. It accepts python values, simple structures and Data objects
44 as values for the Op parameters. It also accepts a single IECore.CompoundObject parameter that is
45 forwarded to the operate method as the values for all the Op parameters.
46 """
47
48 if len(cargs) == 1 and not args and isinstance( cargs[0], IECore.CompoundObject ) :
49 return self.operate( cargs[0] )
50
51 if len(cargs) :
52 raise Exception( "Attempt to call an Op with invalid parameter values!" )
53
54 for (paramName, paramValue) in args.items():
55 if isinstance(paramValue, IECore.Object):
56 self[ paramName ].setValue( paramValue )
57 else:
58 self[ paramName ].setTypedValue( paramValue )
59
60 return self.operate( )
61
62# redefine Op
63IECore.Op.__call__ = __opSmartOperator

Callers

nothing calls this directly

Calls 4

operateMethod · 0.80
lenFunction · 0.50
itemsMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected