import re

from BeautifulSoup import BeautifulSoup

from datafeeds.parser_base import ParserBase


class UsfirstEventTeamsParser(ParserBase):
    @classmethod
    def parse(self, html):
        """
        Find what Teams are attending an Event, and return their team_numbers.
        """

        teamRe = re.compile(r'whats-going-on/team/FRC/[A-Za-z0-9=&;\-:]*?">\d+')
        teamNumberRe = re.compile(r'\d+$')
        tpidRe = re.compile(r'\d+')

        teams = list()
        for teamResult in teamRe.findall(html):
            team = dict()
            team["team_number"] = int(teamNumberRe.findall(teamResult)[0])
            team["first_tpid"] = int(tpidRe.findall(teamResult)[0])
            teams.append(team)

        soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML_ENTITIES)
        more_pages = soup.find('a', {'title': 'Go to next page'}) is not None
        return teams, more_pages

import re

from BeautifulSoup import BeautifulSoup

from datafeeds.parser_base import ParserBase


class UsfirstEventTeamsParser(ParserBase):
    @classmethod
    def parse(self, html):
        """
        Find what Teams are attending an Event, and return their team_numbers.
        """

        teamRe = re.compile(r'whats-going-on\/team\/(\d*)\?ProgramCode=FRC">(\d*)')

        teams = list()
        for first_tpid, team_number in teamRe.findall(html):
            team = dict()
            team["first_tpid"] = int(first_tpid)
            team["team_number"] = int(team_number)
            teams.append(team)

        soup = BeautifulSoup(html, convertEntities=BeautifulSoup.HTML_ENTITIES)
        more_pages = soup.find('a', {'title': 'Go to next page'}) is not None
        return teams, more_pages

Fix event teams parser for new format