Batted ball Code for at bat description
        :param ab_des: at bat description
        :return: battedball_cd(str)
765683
def _battedball_cd(cls, ab_des):
        
        _ab_des = ab_des.lower()
        if ab_des.count("ground")>0:
            return 'G'
        elif _ab_des.count("lines")>0:
            return 'L'
        elif _ab_des.count("flies")>0:
            return 'F'
        elif _ab_des.count("pops")>0:
            return 'P'
        elif _ab_des.count("on a line drive")>0:
            return 'L'
        elif _ab_des.count("fly ball")>0:
            return 'F'
        elif _ab_des.count("ground ball")>0:
            return 'G'
        elif _ab_des.count("pop up")>0:
            return 'P'
        else:
            return ''
431451
def winning_abbr(self):
        
        if self.winner == HOME:
            return utils._parse_abbreviation(self._home_name)
        return utils._parse_abbreviation(self._away_name)
300943
def shortDescription(self):
        '''
        
        '''
        cd = getattr(self,'classDescription',None)
        if cd:
            sd = getattr(cd,'shortDescription','')
            d = getattr(cd,'description','')
            return sd if sd else d
        return ''
372630
def _generate_game_object(cls, soup, timestamp, game_number):
        
        game = Game(timestamp)

        # Base Game Data(Spring Training, Regular Season, Play Off, etc...)
        game.game_type = MlbamUtil.get_attribute(soup.game, 'type', unknown=MlbamConst.UNKNOWN_SHORT)
        game.game_type_des = cls._get_game_type_des(game.game_type)
        game.st_fl = cls._get_st_fl(game.game_type)
        game.regseason_fl = cls._get_regseason_fl(game.game_type)
        game.playoff_fl = cls._get_playoff_fl(game.game_type)
        game.local_game_time = MlbamUtil.get_attribute(soup.game, 'local_game_time', unknown=MlbamConst.UNKNOWN_FULL)
        game.game_id = MlbamUtil.get_attribute(soup.game, 'game_pk', unknown=MlbamConst.UNKNOWN_FULL)

        # Team Data
        game.home_team_id = cls._get_team_attribute(soup, cls.TEAM_TYPE_HOME, 'code')
        game.home_team_lg = cls._get_team_attribute(soup, cls.TEAM_TYPE_HOME, 'league')
        game.away_team_id = cls._get_team_attribute(soup, cls.TEAM_TYPE_AWAY, 'code')
        game.away_team_lg = cls._get_team_attribute(soup, cls.TEAM_TYPE_AWAY, 'league')
        game.home_team_name = cls._get_team_attribute(soup, cls.TEAM_TYPE_HOME, 'name')
        game.away_team_name = cls._get_team_attribute(soup, cls.TEAM_TYPE_AWAY, 'name')
        game.home_team_name_full = cls._get_team_attribute(soup, cls.TEAM_TYPE_HOME, 'name_full')
        game.away_team_name_full = cls._get_team_attribute(soup, cls.TEAM_TYPE_AWAY, 'name_full')
        game.interleague_fl = cls._get_interleague_fl(game.home_team_lg, game.away_team_lg)

        # Stadium Data
        game.park_id = cls._get_stadium_attribute(soup, 'id')
        game.park_name = cls._get_stadium_attribute(soup, 'name')
        game.park_loc = cls._get_stadium_attribute(soup, 'location')

        # Retro ID
        game.retro_game_id = cls._get_retro_id(game.home_team_id, timestamp, game_number)

        return game
77124
def abs(self):
        
        self._validate_dtypes(numeric_only=True)
        return self.__constructor__(query_compiler=self._query_compiler.abs())
1368684
def inform_of_short_bin_name(cls, binary):
        
        binary = os.path.splitext(os.path.basename(binary))[0]
        if binary != 'da':
            msg = '"da" is the preffered way of running "{binary}".'.format(binary=binary)
            logger.logger.info('*' * len(msg))
            logger.logger.info(msg)
            logger.logger.info('*' * len(msg))
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))
1049017
def _get_batter(self, batter):
        
        values = OrderedDict()
        player = self.players.rosters.get(batter.get('id'))
        bo, starting = self._get_batting_order_starting_flg(batter)
        values['bo'] = bo
        values['pos'] = batter.get('pos', MlbamConst.UNKNOWN_SHORT)
        values['id'] = batter.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['starting'] = starting
        return values
1234481
def s2b(s):
    
    ret = []
    for c in s:
        ret.append(bin(ord(c))[2:].zfill(8))
    return "".join(ret)
58531
def get_description(self):
        """"""

        vo = ffi.cast('VipsObject *', self.pointer)
        return _to_string(vips_lib.vips_object_get_description(vo))
958290
def dict2pb(cls, adict, strict=False):
    
    obj = cls()
    for field in obj.DESCRIPTOR.fields:
        if not field.label == field.LABEL_REQUIRED:
            continue
        if not field.has_default_value:
            continue
        if not field.name in adict:
            raise ConvertException('Field "%s" missing from descriptor dictionary.'
                                   % field.name)
    field_names = set([field.name for field in obj.DESCRIPTOR.fields])
    if strict:
        for key in adict.keys():
            if key not in field_names:
                raise ConvertException(
                    'Key "%s" can not be mapped to field in %s class.'
                    % (key, type(obj)))
    for field in obj.DESCRIPTOR.fields:
        if not field.name in adict:
            continue
        msg_type = field.message_type
        if field.label == FD.LABEL_REPEATED:
            if field.type == FD.TYPE_MESSAGE:
                for sub_dict in adict[field.name]:
                    item = getattr(obj, field.name).add()
                    item.CopyFrom(dict2pb(msg_type._concrete_class, sub_dict))
            else:
                # fix python3 map用法变更
                list(map(getattr(obj, field.name).append, adict[field.name]))
        else:
            if field.type == FD.TYPE_MESSAGE:
                value = dict2pb(msg_type._concrete_class, adict[field.name])
                getattr(obj, field.name).CopyFrom(value)
            elif field.type in [FD.TYPE_UINT64, FD.TYPE_INT64, FD.TYPE_SINT64]:
                setattr(obj, field.name, int(adict[field.name]))
            else:
                setattr(obj, field.name, adict[field.name])
    return obj
65426
def is_pa_terminal(cls, ball_tally, strike_tally, pitch_res, event_cd):
        
        # In Play
        if pitch_res == 'X':
            return True
        # Strike Out(Strike or Call)
        elif (pitch_res == 'S' or pitch_res == 'C') and event_cd == 3 and strike_tally == 2:
            return True
        # Walk(Ball or Intent Ball)
        elif pitch_res == 'B' and (event_cd == 14 or event_cd == 15) and ball_tally == 3:
            return True
        return False
979602
def attrs(self):
        """"""
        ret = dict(self.__dict__) # obtain copy of internal __dict__
        del ret["_matches"] # match history is specifically distinguished from player information (and stored separately)
        if self.type != c.COMPUTER: # difficulty only matters for computer playres
            del ret["difficulty"]
        return ret
278190
def dataframe(self):
        
        # If both the runs scored and allowed are None, the game hasn't been
        # played yet, and the DataFrame should be None.
        if self._runs_allowed is None and self._runs_scored is None:
            return None
        fields_to_include = {
            'attendance': self.attendance,
            'boxscore_index': self.boxscore_index,
            'date': self.date,
            'datetime': self.datetime,
            'game_number_for_day': self.game_number_for_day,
            'day_or_night': self.day_or_night,
            'game': self.game,
            'game_duration': self.game_duration,
            'games_behind': self.games_behind,
            'innings': self.innings,
            'location': self.location,
            'loser': self.loser,
            'opponent_abbr': self.opponent_abbr,
            'rank': self.rank,
            'record': self.record,
            'result': self.result,
            'runs_allowed': self.runs_allowed,
            'runs_scored': self.runs_scored,
            'save': self.save,
            'streak': self.streak,
            'winner': self.winner
        }
        return pd.DataFrame([fields_to_include], index=[self._boxscore])
619526
private static byte[] getDecodabet(int options) {
        if ((options & URL_SAFE) == URL_SAFE) {
            return _URL_SAFE_DECODABET;
        } else if ((options & ORDERED) == ORDERED) {
            return _ORDERED_DECODABET;
        } else {
            return _STANDARD_DECODABET;
        }
    }
1256136
def _SignedBinaryURNFromID(binary_id
                          ):
  """"""
  binary_type = binary_id.binary_type
  if binary_type == rdf_objects.SignedBinaryID.BinaryType.PYTHON_HACK:
    return GetAFF4PythonHackRoot().Add(binary_id.path)
  elif binary_type == rdf_objects.SignedBinaryID.BinaryType.EXECUTABLE:
    return GetAFF4ExecutablesRoot().Add(binary_id.path)
  else:
    raise ValueError("Unknown binary type %s." % binary_type)
935635
def get_atbats
      atbats = []
      innings = get_innings
      innings.each do |inning|
        inning.top_atbats.each do |atbat|
          atbats << atbat
        end
        inning.bottom_atbats.each do |atbat|
          atbats << atbat
        end
      end
      atbats
    end