Exemple #1
0
 def from_response(resp, league):
     trans = from_response_object(Transaction(league), resp)
     for player in as_list(_.get(trans, 'players.player', [])):
         tp = TransactionPlayer(trans)
         from_response_object(tp, player.__dict__)
         trans.involved_players.append(tp)
     return trans
Exemple #2
0
    def get_leagues(self, game, season, persist_ttl=DEFAULT_TTL):
        """ Get a list of all leagues for a given game and season

        Args:
            game (str) - the fantasy game we're looking at
            season (int/str) - the fantasy season to get leagues for
        """
        game_id = get_game_id(game, season)
        data = self._load_or_fetch(
            'leagues',
            'users;use_login=1/games;game_keys={}/leagues'.format(game_id))
        leagues = []
        for league_data in as_list(get(
                data, 'fantasy_content.users.user.games.game.leagues.league')):
            league = League(self, get_value(league_data['league_key']))
            from_response_object(league, league_data)
            leagues.append(league)
        return leagues
Exemple #3
0
 def team2_stats(self):
     return self._get_matchup_team_stats(as_list(self.teams.team)[1])
Exemple #4
0
 def team2(self):
     return self.league.get_team(as_list(self.teams.team)[1].team_key)
Exemple #5
0
 def manager(self):
     """ We can have multiple managers, so here's a shortcut to get 1 manager """
     return as_list(self.managers.manager)[0]
Exemple #6
0
 def test_as_list(self):
     self.assertEqual(as_list(5), [5])
     self.assertEqual(as_list([5]), [5])