Ejemplo n.º 1
0
def load_tournament(t):
    LOG.debug("Loading %s %s", t['tournament_id'], t['name'])
    LOG.debug("Loading data for %s", t['tournament_id'])
    tourney_data = load_cached(
        nafparser.parse_tournament,
        "data/tournaments/t{}.html".format(t['tournament_id']))
    LOG.debug("Loading matches for %s", t['tournament_id'])
    match_data = load_cached(
        nafparser.parse_matches,
        "data/matches/m{}.html".format(t['tournament_id']))

    return collate_tournament(t, tourney_data, match_data)
Ejemplo n.º 2
0
def load_matches(tournaments):
    for t in tournaments:
        matchfile = "data/matches/m{}.html".format(t["tournament_id"])
        matches = load_cached(nafparser.parse_matches, matchfile)
        LOG.debug("Tournament {} {} {} matches".format(t["tournament_id"],
                                                       t["name"],
                                                       len(matches)))
        t["matches"] = matches
        yield t
Ejemplo n.º 3
0
def load_all():
    LOG.debug("loading all tournaments")
    result = []

    coaches = load_coaches()
    for t in load_cached(nafparser.parse_tournaments,
                         "data/naf_tourneys.html"):
        yield add_coach_data(tournament=load_tournament(t), coaches=coaches)

    return result
Ejemplo n.º 4
0
def list_tournaments(renew_time=False, force=None):
    """List all naf tournaments from members.thenaf.net"""
    filename = "data/naf_tourneys.html"
    LOG.debug("Listing tournaments")

    if renew_time or force:
        return load_tournaments(renew_time=renew_time, force=force)
    tournaments = load_cached(nafparser.parse_tournaments, filename)

    return tournaments
Ejemplo n.º 5
0
def load_tournaments(renew_time=3600, force=False):
    """List all naf tournaments from members.thenaf.net"""
    filename = "data/naf_tourneys.html"
    LOG.debug("Loading tournaments")
    last_modified = round((time.time() - os.path.getmtime(filename)))
    LOG.debug("data/naf_tourneys.html modified %ss ago", last_modified)

    if force or last_modified > renew_time:
        LOG.debug("Downloading tournamentlist")
        fetch_tournamentlist.fetch_tournamentlist(target=filename)
    else:
        LOG.debug("Using existing tournament data in %s", filename)
        LOG.debug("Skipping download due to last modified %s < %s",
                  last_modified, renew_time)

    tournaments = load_cached(nafparser.parse_tournaments, filename)

    return tournaments