예제 #1
0
    def get_awards(self, event_key=None):
        """Retreives awards json data from API.

        Insert description here.

        Args:
            event_key: string containing key of event. Example: 2015papi

        Returns:
            None

        Raises:
            None

        """
        from TBApython.award import Award

        self.awards.clear()
        if event_key is not None:
            get_awards_url = (API_URL + 'team/' + self.key + '/event/' +
                              event_key + '/awards')
        else:
            get_awards_url = API_URL + 'team/' + self.key + '/history/awards'
        get_awards_raw_data = get_data(get_awards_url)
        for award in get_awards_raw_data:
            this_award = Award()
            this_award.award_from_raw_data(award)
            self.awards.append(this_award)
예제 #2
0
    def get_events(self, year=None):
        """Retreives event json data from API.

        Insert description here.

        Args:
            Year: Integer containing year of interest. Example: 2015

        Returns:
            None

        Raises:
            None

        """
        from TBApython.event import Event

        self.events.clear()
        if year is not None:
            get_events_url = (API_URL + 'team/' + self.key + '/' + str(year) +
                              '/events')
        else:
            get_events_url = API_URL + 'team/' + self.key + '/events'
        get_events_raw_data = get_data(get_events_url)
        for event in get_events_raw_data:
            this_event = Event()
            this_event.event_from_raw_data(event)
            self.events.append(this_event)
예제 #3
0
 def __init__(self, key=None):
     self.key = key
     self.name = None
     self.short_name = None
     self.event_code = None
     self.event_type_string = None
     self.event_type = None
     self.event_district_string = None
     self.event_district = None
     self.year = None
     self.location = None
     self.venue_address = None
     self.website = None
     self.official = None
     self.teams = []
     self.matches = []
     self.awards = []
     self.webcast = None
     self.alliances = None
     self.district_points = None
     self.stats = None
     if key is not None:
         self.url = API_URL + 'event/' + key.lower()
         raw_data = get_data(self.url)
         self = self.event_from_raw_data(raw_data)
     else:
         return None
예제 #4
0
    def get_matches(self, event_key):
        """Retreives match json data from API.

        Insert description here.

        Args:
            event_key: string containing key of event. Example: 2015papi

        Returns:
            None

        Raises:
            None

        """
        from TBApython.match import Match

        self.matches.clear()
        get_matches_url = (API_URL + 'team/' + self.key + '/event/' + event_key
                           + '/matches')
        get_matches_raw_data = get_data(get_matches_url)
        for match in get_matches_raw_data:
            this_match = Match()
            this_match.match_from_raw_data(match)
            self.matches.append(this_match)
예제 #5
0
    def get_matches(self):
        """Retreives match json data from API.

        Insert description here.

        Args:
            None

        Returns:
            None

        Raises:
            None

        """

        from TBApython.match import Match

        self.matches.clear()
        get_matches_url = API_URL + 'event/' + self.key + '/matches'
        get_matches_raw_data = get_data(get_matches_url)
        for match in get_matches_raw_data:
            this_match = Match()
            this_match.match_from_raw_data(match)
            self.matches.append(this_match)
예제 #6
0
 def __init__(self, key=None):
     self.key = key
     self.comp_level = None
     self.set_number = None
     self.match_number = None
     self.alliances = None
     self.score_breakdown = None
     self.event_key = None
     self.videos = None
     self.time_string = None
     self.time = None
     if key is not None:
         self.url = API_URL + 'match/' + key.lower()
         raw_data = get_data(self.url)
         self = self.match_from_raw_data(raw_data)
     else:
         return None
예제 #7
0
 def __init__(self, key=None):
     self.website = None
     self.name = None
     self.locality = None
     self.region = None
     self.team_number = None
     self.key = key
     self.nickname = None
     self.rookie_year = None
     self.events = []
     self.matches = []
     self.awards = []
     self.years_participated = []
     if key is not None:
         self.url = API_URL + 'team/' + key.lower()
         raw_data = get_data(self.url)
         self = self.team_from_raw_data(raw_data)
     else:
         return None
예제 #8
0
    def get_stats(self):
        """Retreives stats json data from API.

        Insert description here.

        Args:
            None

        Returns:
            None

        Raises:
            Raises a StatsFormattingError if raw_data doesn't have proper
            formatting.

        """
        get_stats_url = API_URL + 'event/' + self.key + '/stats'
        get_stats_raw_data = get_data(get_stats_url)
        try:
            self.stats = get_stats_raw_data
        except KeyError:
            raise StatsFormattingError()
예제 #9
0
    def get_years_participated(self):
        """Populates years participated from raw json data.

        Insert description here.

        Args:
            raw_data: string of json data

        Returns:
            self

        Raises:
            Raises a YearsParticipatedFormattingError if raw_data doesn't have
            proper formatting.
        """

        self.years_participated.clear()
        get_years_participated_url = (API_URL + 'team/' + self.key +
                                      '/years_participated')
        get_years_participated_raw_data = get_data(get_years_participated_url)
        try:
            self.years_participated = get_years_participated_raw_data
        except KeyError:
            raise YearsParticipatedFormattingError()
예제 #10
0
    def get_awards(self):
        """Retreives awards json data from API.

        Insert description here.

        Args:
            None

        Returns:
            None

        Raises:
            None

        """
        from TBApython.award import Award

        self.awards.clear()
        get_awards_url = API_URL + 'event/' + self.key + '/awards'
        get_awards_raw_data = get_data(get_awards_url)
        for award in get_awards_raw_data:
            this_award = Award()
            this_award.award_from_raw_data(award)
            self.awards.append(this_award)
예제 #11
0
    def get_teams(self):
        """Retreives team json data from API.

        Insert description here.

        Args:
            None

        Returns:
            None

        Raises:
            None

        """
        from TBApython.team import Team

        self.teams.clear()
        get_teams_url = API_URL + 'event/' + self.key + '/teams'
        get_teams_raw_data = get_data(get_teams_url)
        for team in get_teams_raw_data:
            this_team = Team()
            this_team.team_from_raw_data(team)
            self.teams.append(this_team)