Beispiel #1
0
def test_get_current_team_data():
    """
    summary for current teams
    """
    fetcher = FPLDataFetcher()
    data = fetcher.get_current_team_data()
    assert isinstance(data, dict)
    assert len(data) > 0
Beispiel #2
0
    """
    best_ratio = 0.0
    best_match = None
    for t in fpl_teams:
        if fuzz.partial_ratio(t, team) > best_ratio:
            best_ratio = fuzz.partial_ratio(t, team)
            best_match = t
    print("Best match {}/{}, score {}".format(best_match, team, best_ratio))
    return best_match, best_ratio


if __name__ == "__main__":

    # get the team names as used in FPL
    df = FPLDataFetcher()
    teamdata = df.get_current_team_data()
    teamdict = {
        teamdata[k]["name"]: [teamdata[k]["short_name"]]
        for k in teamdata.keys()
    }

    #    teamdicts = [{teamdata[k]['name']:[teamdata[k]['short_name']]} \
    #                for k in teamdata.keys()]
    fpl_teams = list(teamdict.keys())
    # get the team names from the results csv
    missing = set()
    matched = set()
    history_teams = set()
    for season in ["1415", "1516", "1617", "1718"]:
        filename = "../data/results_{}.csv".format(season)
        for line in open(filename).readlines()[1:]:
Beispiel #3
0
"""

Season details

"""
from datetime import datetime
from airsenal.framework.data_fetcher import FPLDataFetcher


def get_current_season():
    """
    use the current time to find what season we're in.
    """
    current_time = datetime.now()
    if current_time.month > 7:
        start_year = current_time.year
    else:
        start_year = current_time.year - 1
    end_year = start_year + 1
    return "{}{}".format(str(start_year)[2:], str(end_year)[2:])


# make this a global variable in this module, import into other modules
CURRENT_SEASON = get_current_season()

fetcher = FPLDataFetcher()
# TODO make this a database table so we can look at past seasons
CURRENT_TEAMS = [
    t["short_name"] for t in fetcher.get_current_team_data().values()
]