Returns an array of pitches from this game for the pitcher identified by pid
972346
def get_pitches(pid)
      results = []
      atbats = get_atbats
      atbats.each do |ab|
        if ab.pitcher_id == pid
          results << ab.pitches
        end
      end
      results.flatten
    end
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
404537
def roster(team_id):
    """"""
    data = mlbgame.info.roster(team_id)
    return mlbgame.info.Roster(data)
982571
def _read_objects(cls, soup, game):
        
        players = Players()
        players.game = Players.Game()
        # game data
        players.game.venue = soup.game['venue']
        players.game.date = soup.game['date']
        # players & team data
        for team in soup.find_all('team'):
            team_object = cls._get_team(team)
            if team['type'] == Game.TEAM_TYPE_HOME:
                # team data(home)
                players.home_team = team_object
            elif team['type'] == Game.TEAM_TYPE_AWAY:
                # team data(away)
                players.away_team = team_object
            # player data
            players.rosters.update(
                    {player['id']: cls.Player(player, game.retro_game_id) for player in team.find_all('player')}
            )
            # coach data
            players.coaches.update(
                    {coach['id']: cls.Coach(coach, game.retro_game_id, team_object) for coach in team.find_all('coach')}
            )
        # umpire data
        umpires = soup.find('umpires')
        players.umpires.update(
                {umpire['id']: cls.Umpire(umpire, game.retro_game_id) for umpire in umpires.find_all('umpire')}
        )
        return players
59562
def player_stats(game_id):
    """"""
    # get information for that game
    data = mlbgame.stats.player_stats(game_id)
    return mlbgame.stats.Stats(data, game_id, True)
863243
def get_game_logs(self):
        """"""
        logs = self.response.json()['resultSets'][0]['rowSet']
        headers = self.response.json()['resultSets'][0]['headers']
        df = pd.DataFrame(logs, columns=headers)
        df.GAME_DATE = pd.to_datetime(df.GAME_DATE)
        return df
911417
def init_pitcher_from_scoreboard(element)
      @first = element.attributes['first']
      @last = element.attributes['last']
      @wins = element.attributes['wins']
      @losses = element.attributes['losses']
      @era = element.attributes['era']
    end
1027405
def players(game_id):
    """"""
    # get data
    data = mlbgame.data.get_players(game_id)
    # parse data
    parsed = etree.parse(data)
    root = parsed.getroot()

    output = {}
    output['game_id'] = game_id

    # get player/coach data
    for team in root.findall('team'):
        type = team.attrib['type'] + "_team"
        # the type is either home_team or away_team
        output[type] = {}
        output[type]['players'] = []
        output[type]['coaches'] = []

        for p in team.findall('player'):
            player = {}
            for key in p.keys():
                player[key] = p.get(key)
            output[type]['players'].append(player)

        for c in team.findall('coach'):
            coach = {}
            for key in c.keys():
                coach[key] = c.get(key)
            output[type]['coaches'].append(coach)

    # get umpire data
    output['umpires'] = []
    for u in root.find('umpires').findall('umpire'):
        umpire = {}
        for key in u.keys():
            umpire[key] = u.get(key)
        output['umpires'].append(umpire)

    return output
1146440
def pitch(self, shift,
              use_tree=False,
              segment=82,
              search=14.68,
              overlap=12):
        """"""
        self.command.append("pitch")
        if use_tree:
            self.command.append('-q')
        self.command.append(shift)
        self.command.append(segment)
        self.command.append(search)
        self.command.append(overlap)
        return self
739391
def get_opening_day_game(year)
      schedule = Schedule.new(year)
      oday = schedule.get_opening_day
      oday_array = GamedayUtil.parse_date_string(oday)
      games = games_for_date(oday_array[0], oday_array[1], oday_array[2])
      if games[0] == nil
        games = games_for_date(oday_array[0], 
                               oday_array[1], 
                               GamedayUtil.convert_digit_to_string(oday_array[2].to_i + 1))
      end
      return games[0]
    end
1116078
def _get_pitch(self, soup, pa):
        
        pitches = []
        ball_tally, strike_tally = 0, 0
        for pitch in soup.find_all('pitch'):
            # pitching result
            pitch = Pitch.row(pitch, pa, pitches, ball_tally, strike_tally)
            pitches.append(pitch)
            # ball count
            ball_tally, strike_tally = RetroSheet.ball_count(ball_tally, strike_tally, pitch['pitch_res'])
        return pitches
796941
def get_batters(home_or_away)
      if self.gid
        bs = get_boxscore
        if home_or_away == 'away'
        	bs.batters[0]
        else
          bs.batters[1]
        end
      else
        puts "No data for input specified"
      end
    end
1119205
def scoreboard(year, month, day, home=None, away=None):
    
    # get data
    data = mlbgame.data.get_scoreboard(year, month, day)
    # parse data
    parsed = etree.parse(data)
    root = parsed.getroot()
    games = {}
    output = {}
    # loop through games
    for game in root:
        if game.tag == 'data':
            return []
        # get team names
        teams = game.findall('team')
        home_name = teams[0].attrib['name']
        away_name = teams[1].attrib['name']
        # check if teams match parameters
        if (home_name == home and home is not None) \
                or (away_name == away and away is not None) \
                or (away is None and home is None):
            # throw all the data into a complicated dictionary
            game_tag = game.tag
            game_data = game.find('game')
            game_id = game_data.attrib['id']
            game_league = game_data.attrib['league']
            game_status = game_data.attrib['status']
            game_start_time = game_data.attrib['start_time']
            home_team_data = teams[0].find('gameteam')
            home_team = home_name
            home_team_runs = int(home_team_data.attrib['R'])
            home_team_hits = int(home_team_data.attrib['H'])
            home_team_errors = int(home_team_data.attrib['E'])
            away_team_data = teams[1].find('gameteam')
            away_team = away_name
            away_team_runs = int(away_team_data.attrib['R'])
            away_team_hits = int(away_team_data.attrib['H'])
            away_team_errors = int(away_team_data.attrib['E'])
            # check type of game
            if game_tag == 'go_game' or game_tag == 'ig_game':
                try:
                    w_pitcher_data = game.find('w_pitcher')
                    w_pitcher = w_pitcher_data.find('pitcher').attrib['name']
                    w_pitcher_wins = int(w_pitcher_data.attrib['wins'])
                    w_pitcher_losses = int(w_pitcher_data.attrib['losses'])
                except Exception:
                    w_pitcher = ""
                    w_pitcher_wins = 0
                    w_pitcher_losses = 0
                try:
                    l_pitcher_data = game.find('l_pitcher')
                    l_pitcher = l_pitcher_data.find('pitcher').attrib['name']
                    l_pitcher_wins = int(l_pitcher_data.attrib['wins'])
                    l_pitcher_losses = int(l_pitcher_data.attrib['losses'])
                except Exception:
                    l_pitcher = ""
                    l_pitcher_wins = 0
                    l_pitcher_losses = 0
                try:
                    sv_pitcher_data = game.find('sv_pitcher')
                    sv_pitcher = sv_pitcher_data.find('pitcher').attrib['name']
                    sv_pitcher_saves = int(sv_pitcher_data.attrib['saves'])
                except Exception:
                    sv_pitcher = ""
                    sv_pitcher_saves = 0
                output = {
                    'game_id': game_id,
                    'game_tag': game_tag,
                    'game_league': game_league,
                    'game_status': game_status,
                    'game_start_time': game_start_time,
                    'home_team': home_team,
                    'home_team_runs': home_team_runs,
                    'home_team_hits': home_team_hits,
                    'home_team_errors': home_team_errors,
                    'away_team': away_team,
                    'away_team_runs': away_team_runs,
                    'away_team_hits': away_team_hits,
                    'away_team_errors': away_team_errors,
                    'w_pitcher': w_pitcher,
                    'w_pitcher_wins': w_pitcher_wins,
                    'w_pitcher_losses': w_pitcher_losses,
                    'l_pitcher': l_pitcher,
                    'l_pitcher_wins': l_pitcher_wins,
                    'l_pitcher_losses': l_pitcher_losses,
                    'sv_pitcher': sv_pitcher,
                    'sv_pitcher_saves': sv_pitcher_saves
                }
            # games that were not played
            elif game_tag == 'sg_game':
                try:
                    p_pitcher_data = game.findall('p_pitcher')
                    p_pitcher_home_data = p_pitcher_data[0]
                    p_pitcher_home = p_pitcher_home_data.find(
                        'pitcher').attrib['name']
                    p_pitcher_home_wins = int(p_pitcher_home_data.
                                              attrib['wins'])
                    p_pitcher_home_losses = int(p_pitcher_home_data.
                                                attrib['losses'])
                    p_pitcher_away_data = p_pitcher_data[1]
                    p_pitcher_away = p_pitcher_away_data.find(
                        'pitcher').attrib['name']
                    p_pitcher_away_wins = int(p_pitcher_away_data.
                                              attrib['wins'])
                    p_pitcher_away_losses = int(p_pitcher_away_data.
                                                attrib['losses'])
                except Exception:
                    p_pitcher_home = ''
                    p_pitcher_home_wins = 0
                    p_pitcher_home_losses = 0
                    p_pitcher_away = ''
                    p_pitcher_away_wins = 0
                    p_pitcher_away_losses = 0
                output = {
                    'game_id': game_id,
                    'game_tag': game_tag,
                    'game_league': game_league,
                    'game_status': game_status,
                    'game_start_time': game_start_time,
                    'home_team': home_team,
                    'home_team_runs': home_team_runs,
                    'home_team_hits': home_team_hits,
                    'home_team_errors': home_team_errors,
                    'away_team': away_team,
                    'away_team_runs': away_team_runs,
                    'away_team_hits': away_team_hits,
                    'away_team_errors': away_team_errors,
                    'p_pitcher_home': p_pitcher_home,
                    'p_pitcher_home_wins': p_pitcher_home_wins,
                    'p_pitcher_home_losses': p_pitcher_home_losses,
                    'p_pitcher_away': p_pitcher_away,
                    'p_pitcher_away_wins': p_pitcher_away_wins,
                    'p_pitcher_away_losses': p_pitcher_away_losses
                }
            # put this dictionary into the larger dictionary
            games[game_id] = output
    return games
1205486
public function players() : array 
    {
        $returnPlayers = [];

        $players = $this->get(sprintf(self::GAME_ENDPOINT . 'titles/%s/players', $this->titleId));

        if ($players->size === 0) return $returnPlayers;

        foreach ($players->data as $player) {
            $returnPlayers[] = new User($this->client, $player->onlineId);
        }

        return $returnPlayers;
    }
203202
def get_process_pids(self, process):
        """"""
        pids = []
        cmd_line_glob = "/proc/[0-9]*/cmdline"
        cmd_line_paths = glob.glob(cmd_line_glob)
        for path in cmd_line_paths:
            try:
                with open(path, 'r') as f:
                    cmd_line = f.read().strip()
                    if process in cmd_line:
                        pids.append(path.split("/")[2])
            except IOError as e:
                continue
        return pids
328496
def load_from_id(gid, pid)
      @gid = gid
      @pid = pid
      @position = 'P'
      @xml_data = GamedayFetcher.fetch_pitcher(gid, pid)
      @xml_doc = REXML::Document.new(@xml_data)
      @team_abbrev = @xml_doc.root.attributes["team"]
      @first_name = @xml_doc.root.attributes["first_name"]
      @last_name = @xml_doc.root.attributes["last_name"]
      @jersey_number = @xml_doc.root.attributes["jersey_number"]
      @height = @xml_doc.root.attributes["height"]
      @weight = @xml_doc.root.attributes["weight"]
      @bats = @xml_doc.root.attributes["bats"]
      @throws = @xml_doc.root.attributes["throws"]
      @dob = @xml_doc.root.attributes['dob']
      set_opponent_stats
    end
1153467
def _pitch_classes():
    '''
    pitch_classes = ['C', 'D', 'E', 'F', 'G', 'A', 'B']
    semitones = [0, 2, 4, 5, 7, 9, 11]
    return dict([(c, s) for c, s in zip(pitch_classes, semitones)])