<s> from __future__ import division <EOL> from vistrails . core . modules . vistrails_module import ModuleError <EOL> from vistrails . core . modules . basic_modules import Module , Float , Integer <EOL> from vistrails . core . modules . config import ModuleSettings <EOL> import vtk <EOL> from . hasher import vtk_hasher <EOL> from . vtk_wrapper . wrapper import VTKInstanceWrapper <EOL> class vtkBaseInspector ( Module ) : <EOL> _settings = ModuleSettings ( abstract = True ) <EOL> def auto_set_results ( self , vtk_object ) : <EOL> mid = self . moduleInfo [ '<STR_LIT>' ] <EOL> for function in self . outputPorts . keys ( ) : <EOL> if hasattr ( vtk_object , function ) : <EOL> retValues = getattr ( vtk_object , function ) ( ) <EOL> if issubclass ( retValues . __class__ , vtk . vtkObject ) : <EOL> output = VTKInstanceWrapper ( retValues , mid ) <EOL> self . set_output ( function , output ) <EOL> elif isinstance ( retValues , ( tuple , list ) ) : <EOL> result = list ( retValues ) <EOL> for i in xrange ( len ( result ) ) : <EOL> if issubclass ( result [ i ] . __class__ , vtk . vtkObject ) : <EOL> result [ i ] = VTKInstanceWrapper ( result [ i ] , mid ) <EOL> self . set_output ( function , type ( retValues ) ( result ) ) <EOL> else : <EOL> self . set_output ( function , retValues ) <EOL> class vtkDataSetInspector ( vtkBaseInspector ) : <EOL> _settings = ModuleSettings ( abstract = False , signature = vtk_hasher ) <EOL> _input_ports = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> _output_ports = [ ( '<STR_LIT>' , [ Float ] * <NUM_LIT:6> ) , <EOL> ( '<STR_LIT>' , [ Float ] * <NUM_LIT:2> ) , <EOL> ( '<STR_LIT>' , [ Float ] ) , <EOL> ( '<STR_LIT>' , [ Float ] * <NUM_LIT:3> ) , <EOL> ( '<STR_LIT>' , [ Integer ] ) , <EOL> ( '<STR_LIT>' , [ Integer ] ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> def compute ( self ) : <EOL> port_object = None <EOL> if self . has_input ( "<STR_LIT>" ) : <EOL> ic = self . get_input ( "<STR_LIT>" ) <EOL> if hasattr ( ic , "<STR_LIT>" ) : <EOL> ic = ic . vtkInstance <EOL> producer = ic . GetProducer ( ) <EOL> try : <EOL> port_object = producer . GetOutput ( ) <EOL> except AttributeError : <EOL> raise ModuleError ( self , <EOL> "<STR_LIT>" ) <EOL> elif self . has_input ( "<STR_LIT>" ) : <EOL> port_object = self . get_input ( "<STR_LIT>" ) <EOL> if hasattr ( port_object , "<STR_LIT>" ) : <EOL> port_object = port_object . vtkInstance <EOL> if port_object : <EOL> self . auto_set_results ( port_object ) <EOL> class vtkDataSetAttributesInspector ( vtkBaseInspector ) : <EOL> _settings = ModuleSettings ( abstract = False , signature = vtk_hasher ) <EOL> _input_ports = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> _output_ports = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> def compute ( self ) : <EOL> vtk_object = None <EOL> if self . has_input ( "<STR_LIT>" ) : <EOL> vtk_object = self . get_input ( "<STR_LIT>" ) <EOL> if hasattr ( vtk_object , "<STR_LIT>" ) : <EOL> vtk_object = vtk_object . vtkInstance <EOL> if vtk_object : <EOL> self . auto_set_results ( vtk_object ) <EOL> class vtkDataArrayInspector ( vtkBaseInspector ) : <EOL> _settings = ModuleSettings ( abstract = False , signature = vtk_hasher ) <EOL> _input_ports = [ ( '<STR_LIT>' , '<STR_LIT>' ) ] <EOL> _output_ports = [ ( '<STR_LIT>' , [ Float ] ) , <EOL> ( '<STR_LIT>' , [ Float ] * <NUM_LIT:2> ) ] <EOL> def compute ( self ) : <EOL> vtk_object = None <EOL> if self . has_input ( "<STR_LIT>" ) : <EOL> vtk_object = self . get_input ( "<STR_LIT>" ) <EOL> if hasattr ( vtk_object , "<STR_LIT>" ) : <EOL> vtk_object = vtk_object . vtkInstance <EOL> if vtk_object : <EOL> self . auto_set_results ( vtk_object ) <EOL> class vtkPolyDataInspector ( vtkDataSetInspector ) : <EOL> _settings = ModuleSettings ( abstract = False , signature = vtk_hasher ) <EOL> _input_ports = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ] <EOL> _output_ports = [ ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' , [ Integer ] ) , <EOL> ( '<STR_LIT>' , [ Integer ] ) , <EOL> ( '<STR_LIT>' , [ Integer ] ) , <EOL> ( '<STR_LIT>' , [ Integer ] ) , <EOL> ] <EOL> def compute ( self ) : <EOL> vtk_object = None <EOL> if self . has_input ( "<STR_LIT>" ) : <EOL> port_object = self . get_input ( "<STR_LIT>" ) <EOL> if hasattr ( port_object , "<STR_LIT>" ) : <EOL> port_object = port_object . vtkInstance <EOL> producer = port_object . GetProducer ( ) <EOL> try : <EOL> vtk_object = producer . GetOutput ( ) <EOL> except AttributeError : <EOL> raise ModuleError ( self , <EOL> "<STR_LIT>" ) <EOL> elif self . has_input ( "<STR_LIT>" ) : <EOL> vtk_object = self . get_input ( "<STR_LIT>" ) <EOL> if hasattr ( vtk_object , "<STR_LIT>" ) : <EOL> vtk_object = vtk_object . vtkInstance <EOL> if vtk_object : <EOL> self . auto_set_results ( vtk_object ) <EOL> _modules = [ vtkBaseInspector , <EOL> vtkDataSetInspector , <EOL> vtkDataSetAttributesInspector , <EOL> vtkDataArrayInspector , <EOL> vtkPolyDataInspector ] </s>
