Ejemplo n.º 1
0
 def innings_viewer_prompt(self, innings_viewer):
     choices = {
         f"{EMOJIS.get('ASTERISK')}  All Innings": innings_viewer["ALL"]
     }
     for inning, table_viewer in innings_viewer.items():
         if inning == "ALL":
             continue
         choices[
             f"{MENU_NUMBERS.get(int(inning[-2:]), inning[-2:])}  {inning}"] = table_viewer
     choices[f"{EMOJIS.get('BACK')} Return to Previous Menu"] = None
     prompt = "Select an inning to view:"
     return user_options_prompt(choices, prompt)
Ejemplo n.º 2
0
 def prompt_user_choose_method_to_select_game(self):
     subprocess.run(["clear"])
     print_heading("Scraped Data Viewer - Please choose an option below",
                   fg="bright_yellow")
     prompt = "How would you like to locate the game you wish to view?"
     choices = {
         f"{MENU_NUMBERS.get(1)}  Enter Game ID Manually": "MANUAL",
         f"{MENU_NUMBERS.get(2)}  Browse by Team": "TEAM",
         f"{MENU_NUMBERS.get(3)}  Browse by Season": "SEASON",
         f"{EMOJIS.get('BACK')} Return to Previous Menu": None,
     }
     return user_options_prompt(choices, prompt, clear_screen=False)
Ejemplo n.º 3
0
 def select_season_prompt(self):
     prompt = "Select an MLB season from the list below:"
     choices = {f"{MENU_NUMBERS.get(1)}  ALL": "ALL"}
     for num, (year, results) in enumerate(self.app.audit_report.items(),
                                           start=2):
         if results["successful"]:
             choices[f"{MENU_NUMBERS.get(num, str(num))}  {year}"] = year
     choices[f"{EMOJIS.get('BACK')} Return to Previous Menu"] = None
     result = user_options_prompt(choices, prompt)
     if result.failure:
         return result
     year = result.value if isinstance(result.value, int) else None
     return Result.Ok(year)
Ejemplo n.º 4
0
 def select_season_prompt(self):
     subprocess.run(["clear"])
     print_heading("Scraped Data Viewer - Select MLB Season",
                   fg="bright_yellow")
     prompt = "Select an MLB season from the list below:"
     choices = {
         f"{MENU_NUMBERS.get(num, str(num))}  {year}": year
         for num, (
             year,
             results) in enumerate(self.app.audit_report.items(), start=1)
         if results["successful"]
     }
     choices[f"{EMOJIS.get('BACK')} Return to Previous Menu"] = None
     return user_options_prompt(choices,
                                prompt,
                                clear_screen=False,
                                first_item_is_exit_menu=True)
Ejemplo n.º 5
0
 def select_batter_prompt(self, bat_boxscore):
     max_name_length = self.get_name_max_length(bat_boxscore)
     choices = {
         f"{self.select_batter_text(order_num, box, max_name_length)}":
         box["mlb_id"]
         for order_num, box in bat_boxscore.items()
     }
     choices[f"{EMOJIS.get('BACK')} Return to Previous Menu"] = None
     prompt = (
         "Starting lineup and all substitutes who made at least one plate appearance are "
         "listed below. Select a player and press ENTER to view details of each at bat:"
     )
     print_heading(f"Scraped Data Viewer for Game ID: {self.bbref_game_id}",
                   fg="bright_yellow")
     return user_options_prompt(choices,
                                prompt,
                                auto_scroll=False,
                                clear_screen=False)
Ejemplo n.º 6
0
 def select_pitcher_prompt(self, pitch_boxscore):
     max_name_length = self.get_name_max_length(pitch_boxscore)
     choices = {
         f"{self.select_pitcher_text(num, box, max_name_length)}":
         box["mlb_id"]
         for num, box in enumerate(pitch_boxscore.values(), start=1)
     }
     choices[f"{EMOJIS.get('BACK')} Return to Previous Menu"] = None
     prompt = (
         "All pitchers that apppeared in the game are listed below. Select a player and "
         "press ENTER to access information for this start and various career stats:"
     )
     print_heading(f"Scraped Data Viewer for Game ID: {self.bbref_game_id}",
                   fg="bright_yellow")
     return user_options_prompt(choices,
                                prompt,
                                auto_scroll=False,
                                clear_screen=False)
Ejemplo n.º 7
0
 def select_data_prompt(self):
     prompt = (
         f"\nData for {self.bbref_game_id} can be viewed in several different ways, "
         "please choose an option from the list below:")
     choices = {
         f"{MENU_NUMBERS.get(1)}  {self.bat_stats_text(False)}":
         (self.away_team_id, "BAT"),
         f"{MENU_NUMBERS.get(2)}  {self.pitch_stats_text(False)}":
         (self.away_team_id, "PITCH"),
         f"{MENU_NUMBERS.get(3)}  {self.bat_stats_text(True)}":
         (self.home_team_id, "BAT"),
         f"{MENU_NUMBERS.get(4)}  {self.pitch_stats_text(True)}":
         (self.home_team_id, "PITCH"),
         f"{MENU_NUMBERS.get(5)}  All At Bats By Inning": (None, "ALL"),
         f"{MENU_NUMBERS.get(6)}  Game Meta Information": (None,
                                                           "META_INFO"),
         f"{EMOJIS.get('BACK')} Return to Previous Menu":
         None,
     }
     return user_options_prompt(choices, prompt, clear_screen=False)
Ejemplo n.º 8
0
 def select_team_prompt(self):
     team_choices_dict = {
         t.team_id_br: t.name
         for t in db.Team.get_all_teams_for_season(self.db_session,
                                                   year=self.mlb_season)
     }
     subprocess.run(["clear"])
     heading = f"Scraped Data Viewer - Select db.Team (MLB Season: {self.mlb_season})"
     print_heading(heading, fg="bright_yellow")
     prompt = "Select a team from the list below::"
     choices = {
         f"{EMOJIS.get('BLUE_DIAMOND')}  {name} ({team_id})": team_id
         for team_id, name in team_choices_dict.items()
     }
     choices[f"{EMOJIS.get('BACK')} Return to Previous Menu"] = None
     result = user_options_prompt(choices,
                                  prompt,
                                  clear_screen=False,
                                  first_item_is_exit_menu=True)
     if result.failure:
         return result
     self.team_id = result.value
     return self.get_team_game_ids()
Ejemplo n.º 9
0
 def select_pitcher_data_prompt(self, mlb_id):
     pitcher_name = self.game_data.get_player_id_map(mlb_id=mlb_id).mlb_name
     prompt = (
         f"Data for {pitcher_name} can be viewed in several different ways, "
         "please choose an option from the list below:")
     choices = {
         f"{MENU_NUMBERS.get(1)}  Play-by-Play Data for All At Bats":
         "AT_BATS",
         f"{MENU_NUMBERS.get(2)}  Batting Stats By Pitch Type":
         "BAT_STATS",
         f"{MENU_NUMBERS.get(3)}  Pitch Mix Split by Batter Stance":
         "PITCH_MIX_BY_STANCE",
         f"{MENU_NUMBERS.get(4)}  Pitch Mix Split by Season":
         "PITCH_MIX_BY_SEASON",
         f"{MENU_NUMBERS.get(5)}  Plate Discipline Metrics Split by Pitch Type":
         "PLATE_DISCIPLINE",
         f"{MENU_NUMBERS.get(6)}  Batted Ball Metrics Split by Pitch Type":
         "BATTED_BALL",
         f"{EMOJIS.get('BACK')} Return to Previous Menu":
         None,
     }
     print_heading(f"Scraped Data Viewer for Game ID: {self.bbref_game_id}",
                   fg="bright_yellow")
     return user_options_prompt(choices, prompt, clear_screen=False)