Loads a Pitcher object given a game id and a player id
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
873061
def add_object(self, object):
        """"""
        if object.id is None:
            object.get_id()
        self.db.engine.save(object)
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
705807
function loadObject(data, db, callback) {
    callback = callback || function() {};
    var iterator = function(modelName, next){
        insertCollection(modelName, data[modelName], db, next);
    };
    async.forEachSeries(Object.keys(data), iterator, callback);
}
631304
def load_from_id(gid, inning)
      @top_atbats = []
      @bottom_atbats = []
      @gid = gid
      begin
        @xml_data = GamedayFetcher.fetch_inningx(gid, inning)
        @xml_doc = REXML::Document.new(@xml_data)
        if @xml_doc.root
          @num = @xml_doc.root.attributes["num"]
          @away_team = @xml_doc.root.attributes["away_team"]
          @home_team = @xml_doc.root.attributes["home_team"]
          set_top_ab
          set_bottom_ab
        end
      rescue
        puts "Could not load inning file for #{gid}, inning #{inning.to_s}"
      end
    end
364431
function preProcessObject(obj) {
	for (let key in obj) {
		if (!obj.hasOwnProperty(key)) {
			continue;
		}

		let val = obj[key];
		if (key.match(/^steamid_/) && typeof val === 'string' && val != '0') {
			obj[key] = new SteamID(val.toString());
		} else if (key == 'timestamp' || key.match(/^time_/) || key.match(/_timestamp$/)) {
			if (val === 0) {
				obj[key] = null;
			} else if (val !== null) {
				obj[key] = new Date(val * 1000);
			}
		} else if (key == 'clanid' && typeof val === 'number') {
			let id = new SteamID();
			id.universe = SteamID.Universe.PUBLIC;
			id.type = SteamID.Type.CLAN;
			id.instance = SteamID.Instance.ALL;
			id.accountid = val;
			obj[key] = id;
		} else if ((key == 'accountid' || key.match(/^accountid_/) || key.match(/_accountid$/)) && (typeof val === 'number' || val === null)) {
			let newKey = key == 'accountid' ? 'steamid' : key.replace('accountid_', 'steamid_').replace('_accountid', '_steamid');
			obj[newKey] = val === 0 || val === null ? null : SteamID.fromIndividualAccountID(val);
			delete obj[key];
		} else if (key.includes('avatar_sha')) {
			let url = null;
			if (obj[key] && obj[key].length) {
				url = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/chaticons/";
				url += obj[key][0].toString(16) + '/';
				url += obj[key][1].toString(16) + '/';
				url += obj[key][2].toString(16) + '/';
				url += obj[key].toString('hex') + '_256.jpg';
			}

			obj[key.replace('avatar_sha', 'avatar_url')] = url;
		} else if (key.match(/^can_/) && obj[key] === null) {
			obj[key] = false;
		} else if (isDataObject(val)) {
			obj[key] = preProcessObject(val);
		} else if (Array.isArray(val) && val.every(isDataObject)) {
			obj[key] = val.map(v => preProcessObject(v));
		}
	}

	return obj;
}
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
13065
def read_xml(cls, url, markup, game):
        
        return Players._read_objects(MlbamUtil.find_xml("".join([url, cls.FILENAME]), markup) ,game)
586364
public function load()
    {
        $request = new request(self::STEAM_MATCH_URL, array('match_id' => $this->getMatchId()));
        $matchInfo = $request->send();
        if (null === $matchInfo) {
            return null;
        }
        $match = new Match();
        $players = array();
        foreach ($matchInfo->players->player as $key => $player) {
            $players[] = $player;
        }
        $data = (array)$matchInfo;
        unset($data['players']);
        $data['start_time'] = date('Y-m-d H:i:s', $data['start_time']);
        $data['radiant_win'] = ($data['radiant_win'] === 'true') ? '1' : '0';
        $match->setArray($data);
        // slots info
        foreach ($players as $player) {
            $data = (array)$player;
            $data['match_id'] = $this->getMatchId();
            $slot = new Slot();
            $slot->setArray($data);
            // additional_units
            if (array_key_exists('additional_units', $data)) {
                $slot->setAdditionalUnitItems((array)($data['additional_units']->unit));
            }
            // abilities
            if (array_key_exists('ability_upgrades', $data)) {
                $d = (array)$data['ability_upgrades'];
                $abilitiesUpgrade = $d['ability'];
                if (!is_array($abilitiesUpgrade)) {
                    $abilitiesUpgrade = array($abilitiesUpgrade);
                }
                foreach ($abilitiesUpgrade as $k => $v) {
                    $abilitiesUpgrade[$k] = (array)$abilitiesUpgrade[$k];
                }
                $slot->setAbilitiesUpgrade($abilitiesUpgrade);
            }
            $match->addSlot($slot);
        }
        if (isset($matchInfo->picks_bans)) {
            $picksBans = (array)$matchInfo->picks_bans;
            foreach ($picksBans['pick_ban'] as $k => $v) {
                $picksBans['pick_ban'][$k] = (array)$v;
                $picksBans['pick_ban'][$k]['is_pick'] = filter_var($picksBans['pick_ban'][$k]['is_pick'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';
            }
            $match->setAllPickBans($picksBans['pick_ban']);
        }
        return $match;
    }
222373
def box_score(game_id):
    """"""
    # get box score data
    data = mlbgame.game.box_score(game_id)
    # create object with data
    obj = mlbgame.game.GameBoxScore(data)
    return obj
348059
def player(self, player_handle):
        """"""
        try:
            url = self.pubg_url + player_handle
            response = requests.request("GET", url, headers=self.headers)
            return json.loads(response.text)
        except BaseException as error:
            print('Unhandled exception: ' + str(error))
            raise
723592
def load_from_id(gid)
      @gid = gid
      @xml_data = GamedayFetcher.fetch_boxscore(gid)
      @xml_doc = REXML::Document.new(@xml_data)
      if @xml_doc.root
        @game = Game.new(@gid)
        @game.boxscore = self
        set_basic_info
        @linescore = LineScore.new
        @linescore.init(@xml_doc.root.elements["linescore"])
        @home_runs = @linescore.home_team_runs
        @away_runs = @linescore.away_team_runs
        @game_info = @xml_doc.root.elements["game_info"].text
  	    set_batting_text
        set_cities
        set_pitchers
        set_batters
        set_weather
      end
    end
166515
function (connectionName, collectionName, obj, cb) {
        if (_.isObject(obj)) {
            try {
                var modelInstance = new this._model(obj);
                return cb(null, modelInstance);
            }
            catch (err) {
                return cb(err, null);
            }
        }
    }
1034951
def update_umpire_ids_for_games
        ump_id_hp = nil
        ump_id_1b = nil
        ump_id_2b = nil
        ump_id_3b = nil
        res = @db.query("select id, umpire_hp_id, umpire_1b_id, umpire_2b_id, umpire_3b_id from games")
        res.each do |row| # each game
          game_id = row[0]
          umpire_hp_id = row['umpire_hp_id']
          umpire_1b_id = row['umpire_1b_id']
          umpire_2b_id = row['umpire_2b_id']
          umpire_3b_id = row['umpire_3b_id']
        
          # look up umpire record for hp ump
          ump_id_hp = get_first_occurance_of_umpire(umpire_hp_id)
          ump_id_1b = get_first_occurance_of_umpire(umpire_1b_id)
          ump_id_2b = get_first_occurance_of_umpire(umpire_2b_id)
          ump_id_3b = get_first_occurance_of_umpire(umpire_3b_id)
        
          # update game with correct ump ids
          @db.query("UPDATE games SET umpire_hp_id='#{ump_id_hp}',umpire_1b_id='#{ump_id_1b}',
                       umpire_2b_id='#{ump_id_2b}', umpire_3b_id='#{ump_id_3b}' WHERE id=#{game_id}")
        end
      end
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
858477
private Object loadObjectFromField(String fieldname, Object object, Object alternative) throws Exception {
        Object source = object != null ? object : alternative;
        try {
            return FieldUtils.readField(source, fieldname, true);
        } catch (Exception e) {
            throw new IllegalArgumentException(String.format("Unable to load field '%s' from object '%s'", fieldname,
                source.getClass().getName()));
        }
    }
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,
    };
  });
}