def port_and_port_spec_match(self, port, port_spec):
        """Checks whether the ports match, i.e. have the same signature.

        They must also have the same type (both input or both output) and name.

        :type port: Port | PortSpec
        :type port_spec: PortSpec
        :rtype: bool
        """
        if port.type in PortSpec.port_type_map:
            port_type = port.type
        elif port.type in PortSpec.port_type_map.inverse:
            port_type = PortSpec.port_type_map.inverse[port.type]
        else:
            raise TypeError('Port type "%s" invalid' % str(port.type))
        if port_type != port_spec.type:
            return False
        if port.name != port_spec.name:
            return False
        if port.sigstring == port_spec.sigstring:
            return True
        return self.are_specs_matched(port, port_spec)
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/modules/module_registry.py/ModuleRegistry.port_and_port_spec_match/original