MLB module¶
__init__.py¶
-
mlb.
draw_board
()[source]¶ Draw components of MLB game.
Firstly, creates a canvas for the LED matrix using various configurations. Requests games for the day for MLB 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 MLB, then it will go to the next league.
- Returns
Return -1 if no favorite game.
- Return type
int
game.py¶
-
class
mlb.game.
Game
(game_info: Dict[str, any], a_name: str, h_name: str)[source]¶ Represent a scheduled MLB game.
Game object first parses the JSON dict information. Also contains method to get matchup as a simplified dict.
- 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 status, score, and starttime.
- Returns
Game information in a dictionary.
- Return type
Dict[str, str]
-
class
mlb.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 MLB API and checks if games are favorites. If so, then it creates Game objects from the data.
- Returns
List of python dicts that contain information of today’s games.
- Return type
List[Tuple[str, str]]
-
static
teams.py¶
Abbreviation information about MLB teams