NBA module¶
__init__.py¶
-
nba.
draw_board
()[source]¶ Draw components of NBA game.
Firstly, creates a canvas for the LED matrix using various configurations. Requests games for the day for NBA and draws various components of the game such as team logos, scores, period, and time.
“SCORE!!!” animation is disabled by default. User can uncomment it if they want but because frequency of NBA updates, the animation will run every single time. (Recommended to keep it disabled)
If button is pressed during the execution, it will load the next game. If the game is the last one for the day in NBA, then it will go to the next league.
- Returns
Return -1 if no favorite game.
- Return type
int
game.py¶
-
class
nba.game.
Game
(game_info: Dict[str, any])[source]¶ Represent a scheduled NBA game.
Game object first parses the JSON dict information. Also contains methods to check 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 period, game stage, game status, game clock, score, and starttime.
- Returns
Game information in a dictionary.
- Return type
Dict[str, str]
-
is_favorite_match
(favorites: List[str]) → 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
-
class
nba.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 NBA 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.
- Return type
List[Tuple[str, str]]
-
static
teams.py¶
Abbreviation information about NBA teams