def _write_ports(self, port_type, module_name, lines, optional=False,
                     force=False):
        if len(self._instance) == 1:
            type = convert_to_vt_type(self._instance[0])
            if type == None and CDATModule._extra_modules in self._instance[0]:
                force = True
            if force and type == None:
                type = "get_late_type('%s')"%self._instance[0]
            if type != None:
                self._valid_instances.append(self._name)
                lines.append("    reg.add_%s_port(%s, '%s', \n" % (port_type,
                                                                   module_name,
                                                                   self._name))
                lines.append("                       ")
                lines.append("(%s,\n" % type)
                lines.append("                        ")
                if not optional:
                    lines.append("\"%s\"))\n" % self._doc)
                else:
                    lines.append("\"%s\"), True)\n" % self._doc)
        else:
            count = 0
            for i in xrange(len(self._instance)):
                type = convert_to_vt_type(self._instance[i])
                new_force = force
                if type == None and self._instance[i] in CDATModule._extra_modules:
                    new_force = True
                if new_force and type == None:
                    type = "get_late_type('%s')"%self._instance[i]
                if type != None:
                    name = "%s_%s"%(self._name,count)
                    self._valid_instances.append(name)
                    count += 1
                    lines.append("    reg.add_input_port(%s, '%s', \n" % (module_name,
                                                                          name))
                    lines.append("                       ")
                    lines.append("(%s,\n" % type)
                    lines.append("                        ")
                    if not optional:
                        lines.append("\"%s\"))\n" % self._doc)
                    else:
                        lines.append("\"%s\"), True)\n" % self._doc)
dataset/ETHPy150Open VisTrails/VisTrails/contrib/cdat/scripts/cdat_domain.py/CDATItem._write_ports/swapped operands of `in`