Example #1
0
def load_teams(week=None, dialog=None, get_proj_points=False, y3=None):
    """Queries yql and created a list of Team objects containing a list of
    player objects

    Parameters
    ----------
    week: int
        The week to query.  Defaults to None
    dialog: method
         Method returning a token, defaults to None
    get_proj_points: bool
        If set to True calls get_all_points and appends proj_points to all
        player objects.  Defaults to False
    y3: yql.ThreeLegged
        The oauth connection to use for queries.  If None then get_y3() will be
        called.  Defaults to None

    Returns
    -------
    list[team]
        A list of the team objects that were created by the yql query
    """
    league_key = config.get_league_key()
    if y3 is None:
        y3 = get_y3()
    token = get_token(y3, dialog)
    teams = construct_teams_and_players(y3, token, league_key, week)
    if get_proj_points:
        projected_stats = get_all_points()
        for team in teams:
            for player in team.players:
                player.proj_points = projected_stats.get(player.player_id, None)
    return teams
Example #2
0
 def __init__(self):
     super(MonitorWidget, self).__init__()
     self.week = get_week()
     if self.week is None:
         self.week = 1
     consumer_key, consumer_secret = config.get_consumer_secret()
     self.y3 = yql.ThreeLegged(consumer_key, consumer_secret)
     self.token = get_token(self.y3)
     self.league_key = config.get_league_key()
     self.stat_categories = get_stat_categories(
         self.y3, self.token, self.league_key)
     self.roster = 'initial'
     self.teams = load_teams(self.week, self.enter_token, y3=self.y3)
     self.datatable = None
     self.initialise_table()
     self.refresh_rate = config.get_gui_parameter('refresh_rate')
     self.timer = QtCore.QTimer()
     self.timer.timeout.connect(self.update_player_points)
     self.timer.start(self.refresh_rate)