Sets a list of players who had homeruns in this game from data in the master_scoreboard.xml file
332541
def set_homeruns(element)
        @homeruns = []
        element.elements.each("home_runs/player") do |hr|
          player = Player.new
          player.last = hr.attributes['last']
          player.first = hr.attributes['first']
          player.hr = hr.attributes['hr']
          player.std_hr = hr.attributes['std_hr']
          player.team_code = hr.attributes['team_code']
          @homeruns << player
        end
      end
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
252854
def set_innings(element)
        element.elements.each("linescore/inning") { |element|
           @away_innings << element.attributes['away']
           @home_innings << element.attributes['home']
        }
      end
652264
def dataframe(self):
        
        if self._away_runs is None and self._home_runs is None:
            return None
        fields_to_include = {
            'date': self.date,
            'time': self.time,
            'venue': self.venue,
            'attendance': self.attendance,
            'duration': self.duration,
            'time_of_day': self.time_of_day,
            'winner': self.winner,
            'winning_name': self.winning_name,
            'winning_abbr': self.winning_abbr,
            'losing_name': self.losing_name,
            'losing_abbr': self.losing_abbr,
            'away_at_bats': self.away_at_bats,
            'away_runs': self.away_runs,
            'away_hits': self.away_hits,
            'away_rbi': self.away_rbi,
            'away_earned_runs': self.away_earned_runs,
            'away_bases_on_balls': self.away_bases_on_balls,
            'away_strikeouts': self.away_strikeouts,
            'away_plate_appearances': self.away_plate_appearances,
            'away_batting_average': self.away_batting_average,
            'away_on_base_percentage': self.away_on_base_percentage,
            'away_slugging_percentage': self.away_slugging_percentage,
            'away_on_base_plus': self.away_on_base_plus,
            'away_pitches': self.away_pitches,
            'away_strikes': self.away_strikes,
            'away_win_probability_for_offensive_player':
            self.away_win_probability_for_offensive_player,
            'away_average_leverage_index': self.away_average_leverage_index,
            'away_win_probability_added': self.away_win_probability_added,
            'away_win_probability_subtracted':
            self.away_win_probability_subtracted,
            'away_base_out_runs_added': self.away_base_out_runs_added,
            'away_putouts': self.away_putouts,
            'away_assists': self.away_assists,
            'away_innings_pitched': self.away_innings_pitched,
            'away_home_runs': self.away_home_runs,
            'away_strikes_by_contact': self.away_strikes_by_contact,
            'away_strikes_swinging': self.away_strikes_swinging,
            'away_strikes_looking': self.away_strikes_looking,
            'away_grounded_balls': self.away_grounded_balls,
            'away_fly_balls': self.away_fly_balls,
            'away_line_drives': self.away_line_drives,
            'away_unknown_bat_type': self.away_unknown_bat_type,
            'away_game_score': self.away_game_score,
            'away_inherited_runners': self.away_inherited_runners,
            'away_inherited_score': self.away_inherited_score,
            'away_win_probability_by_pitcher':
            self.away_win_probability_by_pitcher,
            'away_base_out_runs_saved': self.away_base_out_runs_saved,
            'home_at_bats': self.home_at_bats,
            'home_runs': self.home_runs,
            'home_hits': self.home_hits,
            'home_rbi': self.home_rbi,
            'home_earned_runs': self.home_earned_runs,
            'home_bases_on_balls': self.home_bases_on_balls,
            'home_strikeouts': self.home_strikeouts,
            'home_plate_appearances': self.home_plate_appearances,
            'home_batting_average': self.home_batting_average,
            'home_on_base_percentage': self.home_on_base_percentage,
            'home_slugging_percentage': self.home_slugging_percentage,
            'home_on_base_plus': self.home_on_base_plus,
            'home_pitches': self.home_pitches,
            'home_strikes': self.home_strikes,
            'home_win_probability_for_offensive_player':
            self.home_win_probability_for_offensive_player,
            'home_average_leverage_index': self.home_average_leverage_index,
            'home_win_probability_added': self.home_win_probability_added,
            'home_win_probability_subtracted':
            self.home_win_probability_subtracted,
            'home_base_out_runs_added': self.home_base_out_runs_added,
            'home_putouts': self.home_putouts,
            'home_assists': self.home_assists,
            'home_innings_pitched': self.home_innings_pitched,
            'home_home_runs': self.home_home_runs,
            'home_strikes_by_contact': self.home_strikes_by_contact,
            'home_strikes_swinging': self.home_strikes_swinging,
            'home_strikes_looking': self.home_strikes_looking,
            'home_grounded_balls': self.home_grounded_balls,
            'home_fly_balls': self.home_fly_balls,
            'home_line_drives': self.home_line_drives,
            'home_unknown_bat_type': self.home_unknown_bat_type,
            'home_game_score': self.home_game_score,
            'home_inherited_runners': self.home_inherited_runners,
            'home_inherited_score': self.home_inherited_score,
            'home_win_probability_by_pitcher':
            self.home_win_probability_by_pitcher,
            'home_base_out_runs_saved': self.home_base_out_runs_saved
        }
        return pd.DataFrame([fields_to_include], index=[self._uri])
664945
def total_scores_in(self, leaderboard_name):
        '''
        
        '''
        return sum([leader[self.SCORE_KEY] for leader in self.all_leaders_from(self.leaderboard_name)])
661798
def print_scoreboard(self):
        """"""
        output = ''
        # parallel dictionaries with innings and scores
        innings = []
        away = []
        home = []
        for x in self:
            innings.append(x['inning'])
            away.append(x['away'])
            home.append(x['home'])
        # go through all the information and make a nice output
        # that looks like a scoreboard
        output += 'Inning\t'
        for x in innings:
            output += str(x) + ' '
        output += '\n'
        for x in innings:
            output += '---'
        output += '\nAway\t' + self.__enumerate_scoreboard(away)
        output += '\nHome\t' + self.__enumerate_scoreboard(home)
        return output
323131
def roster(team_id):
    """"""
    data = mlbgame.data.get_roster(team_id)
    parsed = json.loads(data.read().decode('utf-8'))
    players = parsed['roster_40']['queryResults']['row']
    return {'players': players, 'team_id': team_id}
298923
def init(element, gid)
      @gid = gid
      @pid = element.attributes['id']
      @first = element.attributes['first']
      @last = element.attributes['last']
      @num= element.attributes['num']
      @boxname = element.attributes['boxname']
      @rl, = element.attributes['rl']
      @position = element.attributes['position']
      @status = element.attributes['status']
      @bat_order = element.attributes['bat_order']
      @game_position = element.attributes['game_position']
      @avg = element.attributes['avg']
      @hr = element.attributes['hr']
      @rbi = element.attributes['rbi']
      @wins = element.attributes['wins']
      @losses = element.attributes['losses']
      @era = element.attributes['era']   
      set_extra_info
    end
1251152
def team_players(self, team):
        """"""
        keys = 'shirtNumber name position nationality dateOfBirth'.split()
        data = [{key: player[key] for key in keys} for player in team]
        self.generate_output({'players': data})
122493
def get_pitchers(home_or_away)
      if self.gid
        bs = get_boxscore
        if home_or_away == 'away'
          bs.pitchers[0]
        else
          bs.pitchers[1]
        end
      else
        puts "No data for input specified"
      end
    end
1053054
def read_xml(cls, url, markup, game, players):
        
        innings = Inning(game, players)
        base_url = "".join([url, cls.DIRECTORY])
        # hit location data
        hit_location = cls._read_hit_chart_data(
                MlbamUtil.find_xml('/'.join([base_url, cls.FILENAME_INNING_HIT]), markup)
        )

        # create for atbat & pitch data
        for inning in MlbamUtil.find_xml_all(base_url, markup, cls.TAG, cls.FILENAME_PATTERN):
            soup = MlbamUtil.find_xml("/".join([base_url, inning.get_text().strip()]), markup)
            inning_number = int(soup.inning['num'])
            for inning_type in cls.INNINGS.keys():
                inning_soup = soup.inning.find(inning_type)
                if inning_soup is None:
                    break
                innings._inning_events(inning_soup, inning_number, cls.INNINGS[inning_type], hit_location)
                innings._inning_actions(inning_soup, inning_number, cls.INNINGS[inning_type])
        return innings
872018
def live_scores(self, live_scores):
        """"""
        scores = sorted(live_scores, key=lambda x: x["league"])
        for league, games in groupby(scores, key=lambda x: x["league"]):
            self.league_header(league)
            for game in games:
                self.scores(self.parse_result(game), add_new_line=False)
                click.secho('   %s' % Stdout.utc_to_local(game["time"],
                                                          use_12_hour_format=False),
                            fg=self.colors.TIME)
                click.echo()
110396
def list(ctx, sport):
    
    from .ui import maplist2dict
    from tqdm import tqdm
    from treelib import Node, Tree
    tree = Tree()
    tree.create_node("sports", "root")

    def formatname(o):
        if "name" in o:
            name = o.get("name")
        elif "description" in o:
            name = o.get("description")
        else:
            name = []
        return "{} ({})".format(
            maplist2dict(name).get("en"),
            o["id"]
        )

    if sport:
        sports = [Sport(sport, peerplays_instance=ctx.peerplays)]
    else:
        sports = Sports()

    for sport in tqdm(sports):
        tree.create_node(
            formatname(sport),
            sport["id"],
            parent="root")

        for eg in tqdm(sport.eventgroups):
            tree.create_node(
                formatname(eg),
                eg["id"],
                parent=sport["id"])

            for e in tqdm(eg.events):
                tree.create_node(
                    formatname(e),
                    e["id"],
                    parent=eg["id"])

                for bmg in tqdm(e.bettingmarketgroups):
                    tree.create_node(
                        formatname(bmg),
                        bmg["id"],
                        parent=e["id"])

                    for bm in tqdm(bmg.bettingmarkets):
                        tree.create_node(
                            formatname(bm),
                            bm["id"],
                            parent=bmg["id"])

    tree.show()
578046
public function updateWithScores($scores)
    {
        // Update the winner player.
        if (isset($scores['winnerplayer'])) {
            $player = $this->getPlayer($scores['winnerplayer']);
            if ($player) {
                $this->playerQueryBuilder->save($player);
            }
        }

        // Update remaining players.
        foreach ($this->loggedInPlayers as $player) {
            $this->updatePlayer($player);
        }
        $this->playerQueryBuilder->saveAll($this->loggedInPlayers);
    }
456516
public void addTeamNamesCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(team_names)");
        fifo.add(fifo.size(), buf.toString());
    }
1240091
def get_ranked_players():
    """"""

    rankings_page = requests.get(RANKINGS_URL)
    root = etree.HTML(rankings_page.text)
    player_rows = root.xpath('//div[@id="ranked"]//tr')

    for row in player_rows[1:]:
        player_row = row.xpath('td[@class!="country"]//text()')
        yield _Player(
            name=player_row[1],
            country=row[1][0].get('title'),
            triple_crowns=player_row[3],
            monthly_win=player_row[4],
            biggest_cash=player_row[5],
            plb_score=player_row[6],
            biggest_score=player_row[7],
            average_score=player_row[8],
            previous_rank=player_row[9],
        )
1300035
def standings(date=datetime.now()):
    
    data = mlbgame.info.standings(date)
    return mlbgame.info.Standings(data)