# annoying boilerplate # get access to other sub folders import sys sys.path.append('..') from nhlscrapi._tools import build_enum Strength = build_enum('Even', 'PP', 'SH') class Play(object): def __init__(self): self.play_num = 0 self.period = 0 self.strength = Strength.Even self.time = { "min": 20, "sec": 0 } self.vis_on_ice = { } self.home_on_ice = { } self.event = None
# used by GameKey import nhlscrapi.constants as C from nhlscrapi._tools import build_enum # used by Game from nhlscrapi.games.toi import TOI from nhlscrapi.games.rosters import Rosters from nhlscrapi.games.playbyplay import PlayByPlay from nhlscrapi.games.faceoffcomp import FaceOffComparison from nhlscrapi.games.eventsummary import EventSummary """Enum denoting whether the game is regular season or playoff""" GameType = build_enum(PreSeason=1, Regular=2, Playoffs=3) class GameKey(object): """ Unique identifier for a game. See constants for acceptable seasons and game counts. The key can be initialized by setting key_tup or the set of season, game type and game number. :param season: the season number denoted by year season ends :param game_type: enum, (1) pre season, (2) regular season or (3) playoffs :param game_num: the index number of the game :param key_tup: tuple (season, game_type, game_num) """ def __init__(self, season = C.MIN_SEASON, game_type = GameType.Regular, game_num = 1, key_tup=None): if key_tup is None: self.season = season
from nhlscrapi._tools import build_enum from pprint import pprint EventType = build_enum('Event', 'ShotAttempt', 'Shot', 'Block', 'Miss', 'Goal', 'Hit', 'FaceOff', 'Giveaway', 'Takeaway', 'Penalty', 'Stoppage', 'ShootOutAtt', 'ShootOutGoal', 'PeriodEnd', 'GameEnd', 'ShootOutEnd') """Enum indicating event type.""" class Event(object): """Base class for event codes in the RTSS play-by-play reports""" def __init__(self, event_type=EventType.Event, desc=""): self.event_type = event_type """The :py:class:`.EventType` enum values corresponding to the event.""" self.desc = desc """The RTSS description of the play.""" class ShotAttempt(Event): def __init__(self, event_type=EventType.ShotAttempt): super(ShotAttempt, self).__init__(event_type) self.shooter = {'team': '', 'name': '', 'num': 0} """Shooter info ``{ 'team': team, 'name': name, 'num': num }``""" self.shot_type = "" """Description of shot, e.g. Wrist Shot, et c""" self.dist = 0 """Distance of shot in feet"""
# annoying boilerplate # get access to other sub folders import sys sys.path.append('..') from nhlscrapi._tools import build_enum EventType = build_enum('Event', 'ShotAttempt', 'Shot', 'Block', 'Miss', 'Goal', 'Hit', 'FaceOff', 'Giveaway', 'Takeaway', 'Penalty', 'Stoppage', 'ShootOutAtt', 'ShootOutGoal', 'PenaltyShot', 'PeriodEnd', 'GameEnd', 'ShootOutEnd') class Event(object): def __init__(self, event_type = EventType.Event, desc = ""): self.event_type = event_type self.desc = desc class ShotAttempt(Event): def __init__(self, event_type = EventType.ShotAttempt): super(ShotAttempt, self).__init__(event_type) self.shooter = { 'team': '', 'name': '', 'num': 0 } self.shot_type = "" self.dist = 0 class Goal(ShotAttempt): def __init__(self): super(Goal, self).__init__(EventType.Goal) self.assists = []
import nhlscrapi.constants as C from nhlscrapi._tools import build_enum """Enum denoting whether the game is regular season or playoff""" GameType = build_enum(Regular=2, Playoffs=3) class GameKey(object): """Unique identifying info for a given game. (regular/playoffs, season numer, game number). TODO: JSON serializable""" def __init__(self, season = C.MIN_SEASON, game_type = GameType.Regular, game_num = 1, key_tup=None): if key_tup is None: self.season = season self.game_num = game_num self.game_type = game_type else: self.season, self.game_num, self.game_type = key_tup @property def season(self): return self._season @season.setter def season(self, value): if value < C.MIN_SEASON or value > C.MAX_SEASON: raise ValueError("Only seasons starting from " + str(C.MIN_SEASON) + " until " + str(C.MAX_SEASON)) self._season = int(value) @property
# used by GameKey import nhlscrapi.constants as C from nhlscrapi._tools import build_enum # used by Game from nhlscrapi.games.toi import TOI from nhlscrapi.games.rosters import Rosters from nhlscrapi.games.playbyplay import PlayByPlay from nhlscrapi.games.faceoffcomp import FaceOffComparison from nhlscrapi.games.eventsummary import EventSummary """Enum denoting whether the game is regular season or playoff""" GameType = build_enum(PreSeason=1, Regular=2, Playoffs=3) class GameKey(object): """ Unique identifier for a game. See constants for acceptable seasons and game counts. The key can be initialized by setting key_tup or the set of season, game type and game number. :param season: the season number denoted by year season ends :param game_type: enum, (1) pre season, (2) regular season or (3) playoffs :param game_num: the index number of the game :param key_tup: tuple (season, game_type, game_num) """ def __init__(self, season=C.MIN_SEASON, game_type=GameType.Regular, game_num=1, key_tup=None): if key_tup is None: self.season = season
from nhlscrapi._tools import build_enum from nhlscrapi.scrapr.rtss import RTSS from nhlscrapi.games.repscrwrap import RepScrWrap Strength = build_enum('Even', 'PP', 'SH') """Enum indicating play strength.""" class Play(object): """Contains base level of state info about a given play.""" def __init__(self, play_num=0, period=0, strength=Strength.Even, time={ "min": 20, "sec": 0 }, vis_on_ice={}, home_on_ice={}, event=None): self.play_num = play_num """Number of player who made the play""" self.period = period """Current period""" self.strength = strength """Enum of type :py:class:`.Strength` indicating either even strength, shorthanded, or power play"""