View All-Star Write-ins per league.
 @see https://statsapi.mlb.com/docs/#operation/allStarWriteIns
164630
def all_star_write_ins(league_id, season = nil, options = {})
      options[:season] = season || Time.now.year

      get "/league/#{league_id}/allStarWriteIns", options
    end
1061751
public function onAfterWrite()
    {
        parent::onAfterWrite();

        foreach ($this->Categories() as $category) {
            /**
             * @var BlogCategory $category
             */
            $category->BlogID = $this->ParentID;
            $category->write();
        }

        foreach ($this->Tags() as $tag) {
            /**
             * @var BlogTag $tag
             */
            $tag->BlogID = $this->ParentID;
            $tag->write();
        }
    }
315302
private function determineOutcome()
    {
        $outcome = [];
        
        $players = $this->getPlayers();
        $opponents = $players;

        if ($players === false) {
            return false;
        }

        foreach ($players as $player) {
        
            foreach ($opponents as $opponent) {
    
                // dont play the player against themself
                if ($player->getId() === $opponent->getId())
                {
                    continue;
                }

                // move collection
                $player_move = $player->getLastMoveIndex();
                $opponent_move = $opponent->getLastMoveIndex();

                // verify moves have been set
                if (!is_array($player_move)) {
                    throw new RockPaperScissorsSpockLizardException($player->getName() . ' has not set a move!');
                }

                if (!is_array($opponent_move)) {
                    throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has not set a move!');
                }

                // move labels
                $player_move_label = ucfirst(key($player_move));
                $opponent_move_label = ucfirst(key($opponent_move));

                // map moves to an index
                $player_move_index = $this->getMoveIndex($player_move);
                $opponent_move_index = $this->getMoveIndex($opponent_move);

                // Exceptions
                if (!is_numeric($player_move_index)) {
                    throw new RockPaperScissorsSpockLizardException($player->getName() . ' made an illegal move!');
                }

                if (!is_numeric($opponent_move_index)) {
                    throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' made an illegal move!');
                }

                if (current($player_move) === true) {
                    throw new RockPaperScissorsSpockLizardException($player->getName() . ' has already made this move!');
                }

                if (current($opponent_move) === true) {
                    throw new RockPaperScissorsSpockLizardException($opponent->getName() . ' has already made this move!');
                }

                // compare player with opponent
                if (isset($this->move_outcomes[$player_move_index][$opponent_move_index])) {
                    $outcome['winners'][] = [
                        'player' => $player,
                        'opponent' => $opponent,
                        'description' => $player_move_label . ' ' . $this->move_outcomes[$player_move_index][$opponent_move_index] . ' ' . $opponent_move_label
                    ];
                    $outcome['losers'][] = [
                        'player' => $opponent,
                        'opponent' => $player,
                        'description' => $player_move_label . ' ' . $this->move_outcomes[$player_move_index][$opponent_move_index] . ' ' . $opponent_move_label
                    ];
                } else if (isset($this->move_outcomes[$opponent_move_index][$player_move_index])) {
                    // dont do anything -- we just need to check this in order to determine whether a tie needs to be calculated
                } else {
                    // we just add the tie for the player since the opponent will be added to the ties on later iteration
                    $outcome['ties'][] = [
                        'player' => $player,
                        'opponent' => $opponent,
                        'description' => 'Both played ' . $player_move_label
                    ];
                }
            }
        }

        // mark last moves as played
        foreach ($players as $player) {
            $player->lastMoveIsPlayed();
        }
        
        $this->setOutcome($outcome);
        
        return $this->getRoundOutcome();
    }
738692
def team_stats(game_id):
    
    # get data from data module
    box_score = mlbgame.data.get_box_score(game_id)
    raw_box_score = mlbgame.data.get_raw_box_score(game_id)
    # parse XML
    box_score_tree = etree.parse(box_score).getroot()
    raw_box_score_tree = etree.parse(raw_box_score).getroot()
    # get pitching and batting ingo
    pitching = box_score_tree.findall('pitching')
    batting = box_score_tree.findall('batting')
    # dictionary for output
    output = {}
    output = __team_stats_info(pitching, output, 'pitching')
    output = __team_stats_info(batting, output, 'batting')
    output = __raw_team_stats_info(raw_box_score_tree, output)
    return output
468151
def set_pitchers
      @pitchers, away_pitchers, home_pitchers = [], [], []
      count = 1
      @xml_doc.elements.each("boxscore/pitching[@team_flag='away']/pitcher") { |element| 
        pitcher = PitchingAppearance.new
        pitcher.init(@gid, element, count)
        count += 1
        away_pitchers.push pitcher
      }   
      count = 1
      @xml_doc.elements.each("boxscore/pitching[@team_flag='home']/pitcher") { |element| 
        pitcher = PitchingAppearance.new
        pitcher.init(@gid, element, count)
        count += 1
        home_pitchers.push pitcher
      }   
      @pitchers << away_pitchers
      @pitchers << home_pitchers
    end
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
1354730
def common_all_players(
        season,
        is_only_current_season=0,
        league_id=NbaStats::Constants::LEAGUE_ID_NBA
    )
      NbaStats::Resources::CommonAllPlayers.new(
          get(COMMON_ALL_PLAYERS_PATH, {
              :LeagueID => league_id,
              :Season => season,
              :IsOnlyCurrentSeason => is_only_current_season
          })
      )
    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;
    }
252854
def set_innings(element)
        element.elements.each("linescore/inning") { |element|
           @away_innings << element.attributes['away']
           @home_innings << element.attributes['home']
        }
      end
938352
public function getPOV()
    {
        foreach ($this->owner->players as $player) {
            if ($player->owner) {
                return $player->name;
            }
        }
        return '';
    }
274236
public function majRankPointGame()
    {
        $players = $this->findBy(array(), array('pointGame' => 'DESC'));

        Ranking::addObjectRank($players, 'rankPointGame', array('pointGame'));
        $this->getEntityManager()->flush();
    }
98473
public function actionImportLeagues()
    {
        $client = new Client([
            'apiKey' => $this->apiKey
        ]);

        $leagues = $client->getAllLeagues();
        $count = 0;
        foreach ($leagues as $league) {
            $dbLeague = Yii::createObject([
                'class' => $this->leagueClass,
                'interface_id' => ArrayHelper::getValue($league, 'Id'),
                'name' => ArrayHelper::getValue($league, 'Name'),
                'country' => ArrayHelper::getValue($league, 'Country'),
                'historical_data' => constant(
                    '\drsdre\yii\xmlsoccer\models\League::HISTORICAL_DATA_' .
                    strtoupper(ArrayHelper::getValue($league, 'Historical_Data', 'no'))
                ),
                'fixtures' => filter_var(
                    strtolower(ArrayHelper::getValue($league, 'Fixtures', 'no')),
                    FILTER_VALIDATE_BOOLEAN
                ),
                'livescore' => filter_var(
                    strtolower(ArrayHelper::getValue($league, 'Livescore', 'no')),
                    FILTER_VALIDATE_BOOLEAN
                ),
                'number_of_matches' => ArrayHelper::getValue($league, 'NumberOfMatches', 0),
                'latest_match' => ArrayHelper::getValue($league, 'LatestMatch'),
                'is_cup' => filter_var(
                    strtolower(ArrayHelper::getValue($league, 'IsCup', 'no')),
                    FILTER_VALIDATE_BOOLEAN
                )
            ]);
            /* @var $dbLeague \drsdre\yii\xmlsoccer\models\League */

            if (!$dbLeague->save()) {
                $this->stderr("Failed to import league '{$dbLeague->name}': ", Console::FG_RED);
                $this->stderr("\n");
                foreach ($dbLeague->errors as $attribute => $errors) {
                    foreach ($errors as $error) {
                        $this->stderr("$attribute: $error", Console::BG_YELLOW, Console::FG_BLACK);
                        $this->stderr("\n");
                    }
                }
                $this->stderr("\n");
            } else {
                $count++;
                $this->stdout("League '{$dbLeague->name}' inserted\n");
            }
        }

        $this->stdout("\n");
        $this->stdout("$count leagues imported", Console::FG_GREEN);
        $this->stdout("\n");

        return ExitCode::OK;
    }
711287
private  function _writeGuts()
	{
		$record	  = 0x0080;   // Record identifier
		$length	  = 0x0008;   // Bytes to follow

		$dxRwGut	 = 0x0000;   // Size of row gutter
		$dxColGut	= 0x0000;   // Size of col gutter

		// determine maximum row outline level
		$maxRowOutlineLevel = 0;
		foreach ($this->_phpSheet->getRowDimensions() as $rowDimension) {
			$maxRowOutlineLevel = max($maxRowOutlineLevel, $rowDimension->getOutlineLevel());
		}

		$col_level   = 0;

		// Calculate the maximum column outline level. The equivalent calculation
		// for the row outline level is carried out in _writeRow().
		$colcount = count($this->_colinfo);
		for ($i = 0; $i < $colcount; ++$i) {
			$col_level = max($this->_colinfo[$i][5], $col_level);
		}

		// Set the limits for the outline levels (0 <= x <= 7).
		$col_level = max(0, min($col_level, 7));

		// The displayed level is one greater than the max outline levels
		if ($maxRowOutlineLevel) {
			++$maxRowOutlineLevel;
		}
		if ($col_level) {
			++$col_level;
		}

		$header	  = pack("vv",   $record, $length);
		$data		= pack("vvvv", $dxRwGut, $dxColGut, $maxRowOutlineLevel, $col_level);

		$this->_append($header.$data);
	}
439504
def bwar_pitch(return_all=False):
    
    url = "http://www.baseball-reference.com/data/war_daily_pitch.txt"
    s = requests.get(url).content
    c=pd.read_csv(io.StringIO(s.decode('utf-8')))
    if return_all:
        return c
    else:
        cols_to_keep = ['name_common', 'mlb_ID', 'player_ID', 'year_ID', 'team_ID', 'stint_ID', 'lg_ID',
                        'G', 'GS', 'RA','xRA', 'BIP', 'BIP_perc','salary', 'ERA_plus', 'WAR_rep', 'WAA',
                        'WAA_adj','WAR']
        return c[cols_to_keep]
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)
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
1041750
public void writeAll(java.util.List<String[]> allLines) throws IOException {

        openWriter();
        csvWriter.writeAll(allLines);
    }