Exemple #1
0
    def __init__(self, game_key):
        super(TOI, self).__init__(game_key, HomeTOIRep(game_key))

        self._away = AwayTOIRep(game_key)

        self.__wrapped_home = {}
        self.__wrapped_away = {}
Exemple #2
0
 def __init__(self, game_key):
     super(TOI, self).__init__(game_key, HomeTOIRep(game_key))
     
     self._away = AwayTOIRep(game_key)
     
     self.__wrapped_home = { }
     self.__wrapped_away = { }
Exemple #3
0
class TOI(RepScrWrap):
    """
    Time on ice summary report. Produces the time on ice per shift by player for both home and away.
        
    :param game_key: unique game identifier of type :py:class:`.GameKey`
    """
    def __init__(self, game_key):
        super(TOI, self).__init__(game_key, HomeTOIRep(game_key))
        
        self._away = AwayTOIRep(game_key)
        
        self.__wrapped_home = { }
        self.__wrapped_away = { }
    
    def __wrap(self, shift_d):
        return {
            player_num: ShiftSummary(**summ)
            for player_num, summ in shift_d.items()
        }
    
    @property
    def _home(self):
        return self._rep_reader
        
    @property
    @dispatch_loader('_home', 'parse_shifts')
    def home_shift_summ(self):
        """
        :returns: :py:class:`.ShiftSummary` by player for the home team
        :rtype: dict ``{ player_num: shift_summary_obj }``
        """
        if not self.__wrapped_home:
            self.__wrapped_home = self.__wrap(self._home.by_player)
        
        return self.__wrapped_home
        
    @property
    @dispatch_loader('_away', 'parse_shifts')
    def away_shift_summ(self):
        """
        :returns: :py:class:`.ShiftSummary` by player for the away team
        :rtype: dict ``{ player_num: shift_summary_obj }``
        """
        if not self.__wrapped_away:
            self.__wrapped_away = self.__wrap(self._away.by_player)
        
        return self.__wrapped_away
        
        
    @property
    def all_toi(self):
        """
        Return
    
        :returns: the :py:class:`scrapr.toi.ShiftSummary` by player for the home/away team
        :rtype: dict ``{ 'home/away': { player_num: shift_summary_obj } }``
        """
        return {
            'home': self.home_shift_summ(),
            'away': self.away_shift_summ()
        }
        
    def load_all(self):
        """
        Loads all parts of the report.
        
        :returns: ``self`` or ``None`` if load fails
        """
        if self._home.parse() and self._away.parse():
            return self
        else:
            return None
Exemple #4
0
class TOI(RepScrWrap):
    """
    Time on ice summary report. Produces the time on ice per shift by player for both home and away.

    :param game_key: unique game identifier of type :py:class:`.GameKey`
    """
    def __init__(self, game_key):
        super(TOI, self).__init__(game_key, HomeTOIRep(game_key))

        self._away = AwayTOIRep(game_key)

        self.__wrapped_home = {}
        self.__wrapped_away = {}

    def __wrap(self, shift_d):
        return {
            player_num: ShiftSummary(**summ)
            for player_num, summ in shift_d.items()
        }

    @property
    def _home(self):
        return self._rep_reader

    @property
    @dispatch_loader('_home', 'parse_shifts')
    def home_shift_summ(self):
        """
        :returns: :py:class:`.ShiftSummary` by player for the home team
        :rtype: dict ``{ player_num: shift_summary_obj }``
        """
        if not self.__wrapped_home:
            self.__wrapped_home = self.__wrap(self._home.by_player)

        return self.__wrapped_home

    @property
    @dispatch_loader('_away', 'parse_shifts')
    def away_shift_summ(self):
        """
        :returns: :py:class:`.ShiftSummary` by player for the away team
        :rtype: dict ``{ player_num: shift_summary_obj }``
        """
        if not self.__wrapped_away:
            self.__wrapped_away = self.__wrap(self._away.by_player)

        return self.__wrapped_away

    @property
    def all_toi(self):
        """
        Return

        :returns: the :py:class:`scrapr.toi.ShiftSummary` by player for the home/away team
        :rtype: dict ``{ 'home/away': { player_num: shift_summary_obj } }``
        """
        return {'home': self.home_shift_summ(), 'away': self.away_shift_summ()}

    def load_all(self):
        """
        Loads all parts of the report.

        :returns: ``self`` or ``None`` if load fails
        """
        if self._home.parse() and self._away.parse():
            return self
        else:
            return None