<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def generate_links(self, nodes):
 """ Generate a list of links :param list nodes: A list of nodes from :py:meth:`generate_nodes` :return: list of links :rtype: list """

        new_links = []

        for link in self.links:
            # Expand port name if required
            if INTERFACE_RE.search(link['dest_port'])\
                    or VBQ_INT_RE.search(link['dest_port']):
                int_type = link['dest_port'][0]
                dest_port = link['dest_port'].replace(
                    int_type, PORT_TYPES[int_type.upper()])
            else:
                dest_port = link['dest_port']

            # Convert dest_dev and port to id's
            dest_details = self.convert_destination_to_id(
                link['dest_dev'], dest_port, nodes)

            desc = 'Link from %s port %s to %s port %s' % \
                   (link['source_dev'], link['source_port_name'],
                    dest_details['name'], dest_port)

            new_links.append({'description': desc,
                              'destination_node_id': dest_details['id'],
                              'destination_port_id': dest_details['pid'],
                              'source_port_id': link['source_port_id'],
                              'source_node_id': link['source_node_id']})

        # Remove duplicate links and add link_id
        link_id = 1
        for link in new_links:
            t_link = str(link['source_node_id']) + ':' + \
                str(link['source_port_id'])
            for link2 in new_links:
                d_link = str(link2['destination_node_id']) + ':' + \
                    str(link2['destination_port_id'])
                if t_link == d_link:
                    new_links.remove(link2)
                    break
            link['id'] = link_id
            link_id += 1

            self.add_node_connection(link, nodes)

        return new_links