def get_algorithm_ports(cls):
    input_ports = []
    output_ports = []

    if issubclass(cls, vtk.vtkAlgorithm):
        # We try to instantiate the class here to get the number of
        # ports and to avoid abstract classes
        try:
            instance = cls()
        except TypeError:
            pass
        else:
            for i in xrange(instance.GetNumberOfInputPorts()):
                port_name = "SetInputConnection%d" % i
                port_spec = InputPortSpec(name=port_name,
                                          method_name="SetInputConnection",
                                          port_type="vtkAlgorithmOutput",
                                          docstring=get_doc(cls,
                                                        "SetInputConnection"),
                                          show_port=True,
                                          prepend_params=[i])
                input_ports.append(port_spec)
            for i in xrange(instance.GetNumberOfOutputPorts()):
                port_name = "GetOutputPort%d" % i
                port_spec = OutputPortSpec(name=port_name,
                                           method_name="GetOutputPort",
                                           port_type="vtkAlgorithmOutput",
                                           docstring=get_doc(cls,
                                                             "GetOutputPort"),
                                           show_port=True)
                output_ports.append(port_spec)

    return input_ports, output_ports
Unless we are told otherwise, everything may raise being checked.
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/packages/vtk/vtk_wrapper/parse.py/get_algorithm_ports--crossover with--dataset/ETHPy150Open kayhayen/Nuitka/nuitka/nodes/NodeBases.py/NodeBase.mayRaiseExceptionBool