Example #1
0
class PlayByPlay(RepScrWrap):
  def __init__(self, game_key, extractors = {}, cum_stats = {}):
    super(PlayByPlay, self).__init__(game_key)
    
    self._rtss = RTSS(game_key)

    self.extractors = extractors
    self.cum_stats = cum_stats
  
    self.__have_stats = False
  
  @RepScrWrap.read_banner('_rtss')
  @RepScrWrap.lazy_load('_rtss', 'parse_plays')
  def plays(self):
    if not self.__have_stats:
      self.compute_stats()
      self.__have_stats = True
  
    return self._rtss.plays
  
  @RepScrWrap.read_banner('_rtss')
  @RepScrWrap.lazy_load('_rtss', 'parse_plays_stream')
  def compute_stats(self):
    if not self.__have_stats:
      for play in self._rtss.parse_plays_stream():
        self.__process(play, self.extractors, 'extract')
        self.__process(play, self.cum_stats, 'update')
      self.__have_stats = True
    
    return self.plays
    
  def __process(self, play, d, meth):
    for name, m in d.iteritems():
      getattr(m, meth)(play)
Example #2
0
  def __init__(self, game_key, extractors = {}, cum_stats = {}):
    super(PlayByPlay, self).__init__(game_key)
    
    self._rtss = RTSS(game_key)

    self.extractors = extractors
    self.cum_stats = cum_stats
  
    self.__have_stats = False
Example #3
0
    def __init__(self, game_key, cum_stats={}, init_cs_teams=True, game=None):
        super(PlayByPlay, self).__init__(game_key, RTSS(game_key, game))

        self.cum_stats = cum_stats
        """Dictionary of :py:class:`.AccumulateStats` to be computed"""

        self.init_cs_teams = init_cs_teams
        """Boolean, (default) True if the :py:class:`.AccumulateStats` objects should have team names initialized."""

        self.__have_stats = False
        self.__wrapped_plays = []