Esempio n. 1
0
def getTeamInfo(number):
    data = read_tba.get("team/frc" + str(number) + "/simple")
    name = data["nickname"]
    state = data["state_prov"]
    country = data["country"]

    years = len(read_tba.get("team/frc" + str(number) + "/years_participated"))

    try:
        district = read_tba.get("team/frc" + str(number) +
                                "/districts")[-1]["abbreviation"]
    except Exception:
        district = "None"

    if (state in USA):
        state = USA[state]

    elif (state in Canada):
        state = Canada[state]

    elif (country != "USA" and country != "Canada"):
        state = "All"

    if (district in districts):
        district = districts[district]

    return [name, country, state, district, years]
Esempio n. 2
0
def getMatchesEvent(year, event):
    matches = []
    event_time = getEventTime(event)
    for match in read_tba.get("event/" + str(event) + "/matches/simple"):
        # correctly orders matches pre 2016
        match["actual_time"] = getMatchTime(match, event_time)
        red_teams = len(match["alliances"]["red"]["team_keys"])
        blue_teams = len(match["alliances"]["blue"]["team_keys"])

        if (year > 2004 and red_teams == 3 and blue_teams == 3):
            matches.append(Match(match))
        elif (year <= 2004 and red_teams >= 2 and blue_teams >= 2):
            matches.append(Match(match))

    matches.sort()
    return matches
Esempio n. 3
0
def getEvents(year):
    events = []
    for event in read_tba.get("events/" + str(year) + "/simple"):
        if (event["event_type"] <= 10):
            events.append(event["key"])
    return events
Esempio n. 4
0
def getEventTime(event):
    # for pre 2016 events
    date = read_tba.get("event/" + str(event) + "/simple")["start_date"]
    return int(datetime.datetime.strptime(date, "%Y-%m-%d").timestamp())
Esempio n. 5
0
def getTeams(event):
    return read_tba.get("event/" + str(event) + "/teams/keys")