Returns an array containing the cleanup hitters for each game of the specified season.
 The cleanup hitter is the 4th hitter in the batting order
161471
def get_cleanup_hitters_by_year(year)
      results = []
      games = all_games(year)
      games.each do |game|
        boxscore = game.get_boxscore
        hitters = boxscore.get_cleanup_hitters
        if game.home_team_abbrev == @abrev
          results << hitters[1]
        else
          results << hitters[0]
        end
      end
      results
    end
995465
def season(number)
      seasons.detect { |sea| sea.index.to_i == number.to_i }
    end
684068
public function getAllSlotsDivided()
    {
        $return = array('radiant' => array(), 'dire' => array());
        foreach ($this->_slots as $slot) {
            $team = 'radiant';
            if ($slot->get('player_slot') > 5) {
                $team = 'dire';
            }
            array_push($return[$team], $slot);
        }
        return $return;
    }
1074225
def _nbaSeason(x):
    
    if len(str(x)) == 4:
        try:
            return '{0}-{1}'.format(x, str(int(x) % 100 + 1)[-2:].zfill(2))
        except ValueError: 
            raise ValueError("Enter the four digit year for the first half of the desired season")
    else: raise ValueError("Enter the four digit year for the first half of the desired season")
427394
def _generate_object(cls, soup, game, players):
        

        def get_batter(soup, team_flag):
            batting = soup.find('batting', attrs={'team_flag': team_flag})
            if batting:
                return batting.find_all('batter')
            return []

        def get_pitcher(soup, team_flag):
            pitching = soup.find('pitching', attrs={'team_flag': team_flag})
            if pitching:
                return pitching.find_all('pitcher')
            return []

        box_score = BoxScore(game, players)

        box_score.retro_game_id = game.retro_game_id
        box_score.home_team_id = game.home_team_id
        box_score.away_team_id = game.away_team_id
        box_score.home_batting = [box_score._get_batter(b) for b in get_batter(soup, 'home')]
        box_score.away_batting = [box_score._get_batter(b) for b in get_batter(soup, 'away')]
        box_score.home_pitching = [box_score._get_pitcher(p) for p in get_pitcher(soup, 'home')]
        box_score.away_pitching = [box_score._get_pitcher(p) for p in get_pitcher(soup, 'away')]

        return box_score
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
118017
function players (resp) {
  return base(resp).map(function (player) {
    var names = player.displayLastCommaFirst.split(", ").reverse();
    return {
      firstName: names[0].trim(),
      lastName: (names[1] ? names[1] : "").trim(),
      playerId: player.personId,
      teamId: player.teamId,
    };
  });
}
622488
function cleanup(cleanups, start = 0) {
    for(let i = start; i < cleanups.length; ++i) {
        const res = cleanups[i]();
        if(res && res.then)
            return res.then(() => cleanup(cleanups, i+1));
    }
}
1016310
def season_game_logs(season):
    
    # validate input
    max_year = int(datetime.now().year) - 1
    if season > max_year or season < 1871:
        raise ValueError('Season must be between 1871 and {}'.format(max_year))
    file_name = 'GL{}.TXT'.format(season)
    z = get_zip_file(gamelog_url.format(season))
    data = pd.read_csv(z.open(file_name), header=None, sep=',', quotechar='"')
    data.columns = gamelog_columns
    return data
307120
def get_season_team(self, season_key, season_team_key,stats_type=None):
        
        params = {"stats_type": stats_type}
        season_team_url = self.api_path + 'season/' +  season_key + '/team/' + season_team_key + '/'
        response = self.get_response(season_team_url, params=params)
        return response
1347927
def result(cls, ab, pa, pitch_list):
        
        atbat = OrderedDict()
        atbat['ball_ct'] = MlbamUtil.get_attribute_stats(ab, 'b', int, None)
        atbat['strike_ct'] = MlbamUtil.get_attribute_stats(ab, 's', int, None)
        atbat['pitch_seq'] = ''.join([pitch['pitch_res'] for pitch in pitch_list])
        atbat['pitch_type_seq'] = '|'.join([pitch['pitch_type'] for pitch in pitch_list])
        atbat['battedball_cd'] = RetroSheet.battedball_cd(pa['event_cd'], pa['event_tx'], pa['ab_des'])
        return atbat
791347
public Future<RankedStats> getRankedStats(long summoner, Season season) {
        return new ApiFuture<>(() -> handler.getRankedStats(summoner, season));
    }
939891
def get_closing_pitchers
      results = []
      away_pitchers = get_pitchers('away')
      home_pitchers = get_pitchers('home')
      results << away_pitchers[(away_pitchers.size) - 1]
      results << home_pitchers[(home_pitchers.size) -1]
    end
1111772
def _download(self, timestamp):
        
        games, atbats, pitches = [], [], []
        rosters, coaches, umpires = [], [], []
        boxscores, actions = [], []
        timestamp_params = {
            'year': str(timestamp.year),
            'month': str(timestamp.month).zfill(2),
            'day': str(timestamp.day).zfill(2)
        }

        logging.info('->- Game data download start({year}/{month}/{day})'.format(**timestamp_params))

        base_url = self.DELIMITER.join([self.url, self.PAGE_URL_GAME_DAY.format(**timestamp_params)])
        html = MlbamUtil.find_xml(base_url, self.parser)

        href = self.PAGE_URL_GAME_PREFIX.format(**timestamp_params)
        for gid in html.find_all('a', href=re.compile(href)):
            gid_path = gid.get_text().strip()
            gid_url = self.DELIMITER.join([base_url, gid_path])
            # Read XML & create dataset
            try:
                game = Game.read_xml(gid_url, self.parser, timestamp, MlbAm._get_game_number(gid_path))
                players = Players.read_xml(gid_url, self.parser, game)
                innings = Inning.read_xml(gid_url, self.parser, game, players)
                boxscore = BoxScore.read_xml(gid_url, self.parser, game, players)
            except MlbAmHttpNotFound as e:
                logging.warning(e.msg)
                continue

            # append a dataset
            games.append(game.row())
            rosters.extend([roseter.row() for roseter in players.rosters.values()])
            coaches.extend([coach.row() for coach in players.coaches.values()])
            umpires.extend([umpire.row() for umpire in players.umpires.values()])
            atbats.extend(innings.atbats)
            pitches.extend(innings.pitches)
            actions.extend(innings.actions)
            boxscores.append(boxscore.row())

        # writing csv
        day = "".join([timestamp_params['year'], timestamp_params['month'], timestamp_params['day']])
        for params in (
                {'datasets': games, 'filename': Game.DOWNLOAD_FILE_NAME},
                {'datasets': rosters, 'filename': Players.Player.DOWNLOAD_FILE_NAME},
                {'datasets': coaches, 'filename': Players.Coach.DOWNLOAD_FILE_NAME},
                {'datasets': umpires, 'filename': Players.Umpire.DOWNLOAD_FILE_NAME},
                {'datasets': atbats, 'filename': AtBat.DOWNLOAD_FILE_NAME},
                {'datasets': pitches, 'filename': Pitch.DOWNLOAD_FILE_NAME},
                {'datasets': boxscores, 'filename': BoxScore.DOWNLOAD_FILE_NAME},
                {'datasets': actions, 'filename': InningAction.DOWNLOAD_FILE_NAME},
        ):
            self._write_csv(params['datasets'], params['filename'].format(day=day, extension=self.extension))
        time.sleep(2)

        logging.info('-<- Game data download end({year}/{month}/{day})'.format(**timestamp_params))
745295
def draft_combine_non_stationary_shooting(
        season_year,
        league_id=NbaStats::Constants::LEAGUE_ID_NBA
    )
      NbaStats::Resources::DraftCombineNonStationaryShooting.new(
          get(DRAFT_COMBINE_NON_STATIONARY_SHOOTING_PATH, {
              :LeagueID => league_id,
              :SeasonYear => season_year
          })
      )
    end
1125548
def common_team_roster(
        team_id,
        season,
        league_id=NbaStats::Constants::LEAGUE_ID_NBA
    )
      NbaStats::Resources::CommonTeamRoster.new(
          get(COMMON_TEAM_ROSTER_PATH, {
              :Season => season,
              :LeagueID => league_id,
              :TeamID => team_id
          })
      )
    end
1041681
public function getCleanedFieldAsArray(string $field_name): array
    {
        if (empty($this->initial_data[$field_name])) {
            return [];
        }

        // Usually string "false" from javascript interpreted as true, but it must be false
        if (!\is_array($this->initial_data[$field_name])) {
            return [];
        }

        return (array)$this->initial_data[$field_name];
    }