NHL module¶
__init__.py¶
-
nhl.
draw_board
() → int[source]¶ Draw components of NHL game.
Firstly, creates a canvas for the LED matrix using various configurations. Requests games for the day for NHL and draws various components of the game such as team logos, scores, period, and time.
Also, draws “SCORE!!!” animation for the game if there is an update in the score.
If button is pressed during the execution, it will load the next game. If the game is the last one for the day in NHL, then it will go to the next league.
- Returns
Return -1 if no favorite game.
- Return type
int
game.py¶
-
class
nhl.game.
Game
(game_info: Dict[str, any])[source]¶ Represent a scheduled NHL game
Game object first parses the JSON dict information. Also contains methods to check if the game is scheduled today and if the game is of a favorite team.
- Parameters
game_info (Dict[str, any]) – Dictionary generated from JSON object
-
get_matchup
() → Dict[str, str][source]¶ Get information of a single game.
Simply game information into a dictionary to be used by the draw_board() function. Returns a dictionary with names for home and away team, game stage, game status, game clock, score. If the game stage is in progress and the status is live or pre, then also includes time and period fields.
- Returns
Game information in a dictionary.
- Return type
Dict[str, str]
-
is_favorite_match
() → bool[source]¶ Check if game has a team favorited by the user.
Since only the games included in the favorite config are shown, this function checks that either home or away team is a favorite.
- Returns
True if game if either home or away team is a favorite.
- Return type
bool
-
is_scheduled_for_today
() → bool[source]¶ Check if game is scheduled for today.
The scoreboard is used to show only the games scheduled for the current day. Since the NHL API returns a JSON with games for the entire week, this function is used to pick out the games for the current day.
- Returns
True if game if scheduled for today.
- Return type
bool
-
class
nhl.game.
Scores
[source]¶ Scores Class with static function to get scores for the leauge.
-
static
get_scores
() → List[Tuple[str, str]][source]¶ Get a list of favorite scores/games that are on-going or planned for the day.
First, calls for the request of JSON from NHL API and creates Game objects from the data. Then, checks for the games scheduled for the day and if the games are favorites.
- Returns
List of python dicts that contain information of today’s games. Empty list if no games fit the criteria.
- Return type
List[Tuple[str, str]]
-
static
fix_names.py¶
-
nhl.fix_names.
fix_name
(team_name: str) → str[source]¶ Expand some team names from the values in JSON.
Some of the names for NHL teams used in the API JSON are incorrect. In the sense that they omit certain words of the team name. This function fixes that inconsistency.
- Parameters
team_name (str) – Shortened name of the team
- Returns
Expanded name of the team (without city)
- Return type
str
teams.py¶
Abbreviation information about NHL teams