Return iterable containing players on bench who are available to play,
    where each player is a dict containing:

    - name
    - details
    - opponent
517396
def alternates(page):
    
    soup = BeautifulSoup(page)
    try:
        bench = soup.find_all('tr', class_='bench')
        bench_bios = [p.find('div', class_='ysf-player-name') for p in bench]
        names = [p.find('a').text for p in bench_bios]
        details = [p.find('span').text for p in bench_bios]
        opponents = [p.find_all('td', recursive=False)[3].text for p in bench]
        players = [{'name': n, 'details': d, 'opponent': o}
                   for (n, d, o) in zip(names, details, opponents)]
        return [p for p in players if len(p['opponent']) > 0]
    except:
        return None
1132536
def teams(self):
        """"""
        teams = {}
        default_team = 1
        for i in range(1, self._header.replay.num_players):
            attributes = self._header.initial.players[i].attributes
            team = self._header.lobby.teams[i - 1]
            if team == 1:
                team = default_team
                default_team += 1
            if team not in teams:
                teams[team] = {'player_numbers': []}
            teams[team]['player_numbers'].append(attributes.player_color + 1)
        return list(teams.values())
698209
def team(self):
        """"""
        team_dict = self._json_data.get('team')
        if team_dict and team_dict.get('id'):
            return self._client.team(id=team_dict.get('id'))
        else:
            return None
841484
def next_player(self):
        
        logging.warning('turn={}, players={}'.format(
            self.game._cur_turn,
            self.game.players
        ))
        return self.game.players[(self.game._cur_turn + 1) % len(self.game.players)]
1055843
def get_members(self, offset=None, limit=None):
        
        extra = {
            'resource': self.__class__.__name__,
            'query': {'id': self.id}
        }
        logger.info('Get team members', extra=extra)
        response = self._api.get(
            url=self._URL['members_query'].format(id=self.id),
            params={'offset': offset, 'limit': limit}
        )
        data = response.json()
        total = response.headers['x-total-matching-query']
        members = [TeamMember(api=self._api, **member) for member in
                   data['items']]
        links = [Link(**link) for link in data['links']]
        href = data['href']
        return Collection(resource=TeamMember, href=href, total=total,
                          items=members, links=links, api=self._api)
239050
def parse_rosters(self):
        
        lx_doc = self.html_doc()

        if not self.__blocks:
            self.__pl_blocks(lx_doc)

        for t in ['home', 'away']:
            self.rosters[t] = self.__clean_pl_block(self.__blocks[t])

        return self if self.rosters else None
199823
def get_player_stats(self, player_key, board_key):
        
        player_stats_url = self.api_path + 'player/' + player_key + '/league/' + board_key + '/stats/'
        response = self.get_response(player_stats_url)
        return response
2649
def users(self):
        
        friends = [MyPlexUser(self, elem) for elem in self.query(MyPlexUser.key)]
        requested = [MyPlexUser(self, elem, self.REQUESTED) for elem in self.query(self.REQUESTED)]
        return friends + requested
600467
def _members(self):
        
        return {
            key: value
            for key, value in self.__dict__.items()
            # NB: ignore internal SQLAlchemy state and nested relationships
            if not key.startswith("_") and not isinstance(value, Model)
        }
650026
def _get_pitcher(self, pitcher):
        
        values = OrderedDict()
        player = self.players.rosters.get(pitcher.get('id'))
        values['pos'] = pitcher.get('pos', MlbamConst.UNKNOWN_SHORT)
        values['id'] = pitcher.get('id', MlbamConst.UNKNOWN_SHORT)
        values['first'] = player.first
        values['last'] = player.last
        values['box_name'] = player.box_name
        values['rl'] = player.rl
        values['bats'] = player.bats
        values['out'] = pitcher.get('out', MlbamConst.UNKNOWN_SHORT)
        values['bf'] = pitcher.get('bf', MlbamConst.UNKNOWN_SHORT)
        return values
237172
def check_teams
      return if @teams.size == 0
      member = Hash.new
      @teams.each do |t|
        t.members.each do |m|
          raise "member #{m} of team '#{t.name}' is not a valid player number for this tournament" unless @player[m]
          raise "member #{m} of team '#{t.name}' is already a member of team #{member[m]}" if member[m]
          member[m] = t.name
        end
      end
      @player.keys.each do |p|
        raise "player #{p} is not a member of any team" unless member[p]
      end
    end
756596
def get_player_summaries(players, **kwargs):
    
    if (isinstance(players, list)):
        params = {'steamids': ','.join(str(p) for p in players)}
    elif (isinstance(players, int)):
        params = {'steamids': players}
    else:
        raise ValueError("The players input needs to be a list or int")
    return make_request("GetPlayerSummaries", params, version="v0002",
        base="http://api.steampowered.com/ISteamUser/", **kwargs)
114969
def users(self, team, params={}, **options): 
        
        path = "/teams/%s/users" % (team)
        return self.client.get_collection(path, params, **options)
844341
def get_queryset(self):
        

        query_params = self.request.query_params
        url_params = self.kwargs

        # get queryset_filters from FilterMixin
        queryset_filters = self.get_db_filters(url_params, query_params)

        # This dict will hold filter kwargs to pass in to Django ORM calls.
        db_filters = queryset_filters['db_filters']

        # This dict will hold exclude kwargs to pass in to Django ORM calls.
        db_excludes = queryset_filters['db_excludes']

        queryset = Team.objects.prefetch_related(
            'players'
        ).all()

        return queryset.filter(**db_filters).exclude(**db_excludes)
989602
def opponent_name(self):
        
        name = re.sub(r'\(\d+\)', '', self._opponent_name)
        name = name.replace(u'\xa0', '')
        return name
1105904
def gone_online(stream):
    
    while True:
        packet = yield from stream.get()
        session_id = packet.get('session_key')
        if session_id:
            user_owner = get_user_from_session(session_id)
            if user_owner:
                logger.debug('User ' + user_owner.username + ' gone online')
                # find all connections including user_owner as opponent,
                # send them a message that the user has gone online
                online_opponents = list(filter(lambda x: x[1] == user_owner.username, ws_connections))
                online_opponents_sockets = [ws_connections[i] for i in online_opponents]
                yield from fanout_message(online_opponents_sockets,
                                          {'type': 'gone-online', 'usernames': [user_owner.username]})
            else:
                pass  # invalid session id
        else:
            pass
558818
def players_from_fantasypros_cheatsheet(file):
    

    with open(file, newline='') as csvfile:
        # Note - considered using a generator for this, but I don't want to hold the file open
        # for a long time and it's pretty small anyway.
        players = []
        playerindex = 0
        playerreader = reader(csvfile, delimiter=',')
        linecount = 0
        for row in playerreader:
            if linecount > 1:
                raw_name = row[0]
                name = raw_name[:raw_name.find('(') - 1]
                position_text = raw_name[raw_name.find('(') + 1:raw_name.find('-') - 1]
                position = Position[position_text]
                value = int(row[2].replace('$', ''))
                players.append(Player(name, position, value, linecount-2))
                playerindex += 1
            linecount += 1
    return players