示例#1
0
 def game_bar_format(self):
     SUCCESS = EMOJIS.get("PASSED", "")
     FAIL = EMOJIS.get("FAILED", "")
     ERROR = EMOJIS.get("CONFUSED", "")
     return (
         "{desc}{desc_pad}{percentage:3.0f}% |{bar}| " +
         self.terminal.green3(f"{SUCCESS}" + " {count_0:{len_total}d}") +
         " | " + self.terminal.red2(f"{FAIL}" + " {count_1:{len_total}d}") +
         " | " +
         self.terminal.yellow2(f"{ERROR}" + " {count_2:{len_total}d}") +
         " | ETA: {eta}")
示例#2
0
def multi_season_prompt(db_session, prompt=None, heading=None):
    if not prompt:
        prompt = "Select one or multiple seasons from the list below:"
    all_seasons = db.Season.get_all_regular_seasons(db_session)
    choices = {f"{season.year}": season.year for season in all_seasons}
    instructions = "(use SPACE BAR to select each file type, ENTER to confirm your selections)"
    seasons_prompt = Check(
        prompt=instructions,
        choices=list(choices.keys()),
        check=EMOJIS.get("CHECK", ""),
        shift=1,
        indent=0,
        margin=2,
        check_color=colors.foreground["default"],
        check_on_switch=colors.foreground["default"],
        word_color=colors.foreground["default"],
        word_on_switch=colors.bright(colors.foreground["cyan"]),
        background_color=colors.background["default"],
        background_on_switch=colors.background["default"],
    )
    selected_years = []
    while not selected_years:
        subprocess.run(["clear"])
        if heading:
            print_heading(heading, fg="bright_yellow")
        print_message(prompt, wrap=True)
        result = seasons_prompt.launch()
        if not result:
            print_error("\nYou must select at least one season!")
            pause(message="Press any key to continue...")
            continue
        selected_years = [choices[sel] for sel in result]
    return selected_years
示例#3
0
def file_types_prompt(prompt, valid_file_types=VigFile.ALL):
    if not prompt:
        prompt = "Select one or multiple file types from the list below:"
    choices = {f"{f}": f for f in VigFile if int(f) & valid_file_types == f}
    instructions = "(use SPACE BAR to select each file type, ENTER to confirm your selections)"
    file_types_prompt = Check(
        prompt=instructions,
        choices=list(choices.keys()),
        check=EMOJIS.get("CHECK", ""),
        shift=1,
        indent=0,
        margin=2,
        check_color=colors.foreground["default"],
        check_on_switch=colors.foreground["default"],
        word_color=colors.foreground["default"],
        word_on_switch=colors.bright(colors.foreground["cyan"]),
        background_color=colors.background["default"],
        background_on_switch=colors.background["default"],
    )
    file_types = []
    while not file_types:
        subprocess.run(["clear"])
        print_message(prompt, fg="bright_yellow", bold=True, underline=True)
        result = file_types_prompt.launch()
        if not result:
            print_error("\nYou must select at least one file type!")
            pause(message="Press any key to continue...")
            continue
        file_types = [choices[sel] for sel in result]
    return file_types
示例#4
0
 def __init__(self, app):
     # TODO: New Status Report menu option - Single Game. User can provide either BB or BR ID
     # TODO: Another Status Report option - Pitch Appearance. Simply call .display() method
     super().__init__(app)
     self.menu_item_text = "Status Reports"
     self.menu_item_emoji = EMOJIS.get("CHART")
     self.exit_menu = False
示例#5
0
 def __init__(self, app):
     super().__init__(app)
     self.id_map_task = UpdatePlayerIdMapTask(self.app)
     self.team_map_task = UpdatePlayerTeamMapTask(self.app)
     self.menu_item_text = " Update Player ID/Team Map"
     self.menu_item_emoji = EMOJIS.get("TABBED_FILES")
     self.menu_heading = self._menu_item_text
示例#6
0
 def __init__(self, app):
     super().__init__(app)
     self.calc_pitch_times = CalculateAvgPitchTimesTask(app)
     self.menu_item_text = "Calculate Avg. Time Between Pitches"
     self.menu_item_emoji = EMOJIS.get("CLOCK")
     self.exit_menu = False
     self.spinner = Halo(spinner=get_random_dots_spinner(), color=get_random_cli_color())
     self.game_ids = []
示例#7
0
 def __init__(self, app):
     super().__init__(app)
     self.menu_item_text = "View Scraped Game Data"
     self.menu_item_emoji = EMOJIS.get("MICROSCOPE", "")
     self.exit_menu = False
     self.menu_option = None
     self.mlb_season = None
     self.team_id = None
     self.game_id = None
示例#8
0
 def __init__(self, app):
     super().__init__(app)
     self.add_to_db = AddToDatabaseTask(app)
     self.menu_item_text = "Add Combined Game Data to Database"
     self.menu_item_emoji = EMOJIS.get("BASEBALL")
     self.exit_menu = False
     self.spinner = Halo(spinner=get_random_dots_spinner(),
                         color=get_random_cli_color())
     self.game_ids = []
示例#9
0
 def __init__(self, app, setting_name):
     super().__init__(app)
     self.menu_item_text = setting_name
     self.menu_item_emoji = EMOJIS.get("SPIRAL")
     self.setting_name = setting_name
     self.current_setting = self.dotenv.get_current_value(setting_name)
     self.restart_required = self.dotenv.restart_required_on_change(
         setting_name)
     self.exit_menu = False
示例#10
0
 def __init__(self, app, year, bbref_game_ids):
     super().__init__(app)
     self.combine_data = CombineScrapedDataTask(app)
     self.patch_all_invalid_pfx = PatchAllInvalidPitchFxTask(app)
     self.patch_invalid_pfx = PatchInvalidPitchFxTask(app)
     self.year = year
     self.bbref_game_ids = bbref_game_ids
     self.menu_item_text = f"{AuditError.INVALID_PITCHFX_DATA} ({self.game_count} Games)"
     self.menu_item_emoji = EMOJIS.get("UPSIDE_DOWN")
     self.menu_heading = self._menu_item_text
示例#11
0
 def __init__(self, app):
     super().__init__(app)
     self.task = FixOrphanedPlayerIdsTask(self.app)
     self.menu_item_text = "Fix Orphaned Player IDs"
     self.menu_item_emoji = EMOJIS.get("FAMILY")
     self.menu_heading = self._menu_item_text
     self.spinner = None
     self.total_player_ids = 0
     self.fixed = []
     self.skipped = []
     self.last_player_processed = None
示例#12
0
 def __init__(self, app):
     super().__init__(app)
     self.backup_db = BackupDatabaseTask(self.app)
     self.menu_item_text = " Export Database to CSV"
     self.menu_item_emoji = EMOJIS.get("TABBED_FILES")
     self.exit_menu = False
     self.spinner = Halo(spinner=get_random_dots_spinner(),
                         color=get_random_cli_color())
     self.table_count = 0
     self.total_tables = 0
     self.row_count = 0
     self.total_rows = 0
示例#13
0
 def __init__(self, app):
     # TODO: Improve Create Job UX:
     #  - Create new input type that is initialized with a list of valid values
     #  - Order list of values and the selected value can be changed with <- and -> arrow keys
     #  - This input type does not replace the options prompt with numbered items
     #  - This should be used for numbers and dates, like a slider element
     #  - In this menu, it will be used to select start/end dates
     #    - Separate inputs for month and day (user will select year first before data sets)
     super().__init__(app)
     self.menu_item_text = "Create New Job"
     self.menu_item_emoji = EMOJIS.get("KNIFE", "")
     self.menu_heading = self._menu_item_text
示例#14
0
def data_sets_prompt(
    heading: str = None,
    prompt: str = None,
    valid_data_sets: Optional[List[DataSet]] = None,
    checked_data_sets: Optional[List[DataSet]] = None,
):
    if not prompt:
        prompt = "Select one or multiple data sets from the list below:"
    if not valid_data_sets:
        valid_data_sets = [DataSet.ALL]
    instructions = "(use SPACE BAR to select each data set, ENTER to confirm your selections)"
    valid_data_sets_int = sum(int(ds) for ds in valid_data_sets)
    choices = {
        f"{DATA_SET_TO_NAME_MAP[ds]}": ds
        for ds in DataSet if valid_data_sets_int & ds == ds
    }
    if checked_data_sets:
        checked_int = sum(int(ds) for ds in checked_data_sets)
        checked_data_sets = [
            f"{DATA_SET_TO_NAME_MAP[ds]}" for ds in DataSet
            if checked_int & ds == ds
        ]
    ds_prompt = DataSetCheck(
        prompt=instructions,
        choices=list(choices.keys()),
        checked_data_sets=checked_data_sets,
        check=EMOJIS.get("CHECK", ""),
        shift=1,
        indent=0,
        margin=2,
        check_color=colors.foreground["default"],
        check_on_switch=colors.foreground["default"],
        background_color=colors.foreground["default"],
        background_on_switch=colors.foreground["default"],
        word_color=colors.foreground["default"],
        word_on_switch=colors.bright(colors.foreground["cyan"]),
    )
    data_sets = []
    while not data_sets:
        subprocess.run(["clear"])
        if heading:
            print_heading(heading, fg="bright_yellow")
        print_message(prompt, wrap=True)
        result = ds_prompt.launch()
        if not result:
            print_error("\nYou must select at least one data set!")
            pause(message="Press any key to continue...")
            continue
        data_sets = [DATA_SET_FROM_NAME_MAP[sel] for sel in result]
    return data_sets
示例#15
0
 def __init__(self, app):
     super().__init__(app)
     self.s3_sync = SyncScrapedDataTask(self.app)
     self.year = None
     self.sync_direction = ""
     self.file_types = []
     self.sync_tasks = defaultdict(list)
     self.sync_files = defaultdict(dict)
     self.sync_results = []
     self.task_number = 0
     self.spinners = defaultdict(dict)
     self.menu_item_text = " Synchronize Scraped Data"
     self.menu_item_emoji = EMOJIS.get("CLOUD", "")
     self.menu_heading = self.menu_item_text
     self.exit_menu = False
示例#16
0
 def __init__(self, app):
     super().__init__(app)
     self.combine_data = CombineScrapedDataTask(app)
     self._season = None
     self._date_game_id_map = {}
     self.pbar_manager = enlighten.get_manager()
     self.menu_item_text = "Combine Game Data"
     self.menu_item_emoji = EMOJIS.get("BANG", "")
     self.exit_menu = False
     self.combine_condition = self.app.get_current_setting(
         "SCRAPED_DATA_COMBINE_CONDITION")
     self.audit_type = None
     self.scrape_year = None
     self.current_game_date = None
     self.current_game_id = None
     self.combine_data_success_game_ids = []
     self.combine_data_fail_results = {}
     self.all_pfx_errors = defaultdict(dict)
     self.status_bar = None
     self.date_progress_bar = None
     self.game_progress_bar_success = None
     self.game_progress_bar_fail = None
     self.game_progress_bar_error = None
示例#17
0
 def __init__(self, app, year, bbref_game_ids):
     super().__init__(app)
     self.year = year
     self.bbref_game_ids = bbref_game_ids
     self.menu_item_text = f"{AuditError.PITCHFX_ERROR} ({self.game_count} Games)"
     self.menu_item_emoji = EMOJIS.get("CRYING")
示例#18
0
 def get_emoji_for_lineup_slot(self, lineup_slot):
     emoji_num = MENU_NUMBERS.get(lineup_slot)
     if emoji_num:
         return f"{emoji_num} "
     return EMOJIS.get("CAP")
示例#19
0
 def __init__(self, app, bbref_game_id):
     super().__init__(app)
     self.bbref_game_id = bbref_game_id
     self.menu_item_text = bbref_game_id
     self.menu_item_emoji = EMOJIS.get("NEWSPAPER")
示例#20
0
 def __init__(self, app):
     super().__init__(app)
     self.menu_text = "Jobs are grouped according to their current status:"
     self.menu_item_text = "View All Jobs"
     self.menu_item_emoji = EMOJIS.get("ROBOT", "")
示例#21
0
 def __init__(self, app, menu_item_text):
     super().__init__(app)
     self.menu_item_text = menu_item_text
     self.menu_item_emoji = EMOJIS.get("BACK", "")
     self.exit_menu = True
示例#22
0
 def __init__(self, app):
     super().__init__(app)
     self.menu_item_text = "Exit"
     self.menu_item_emoji = EMOJIS.get("EXIT", "")
     self.exit_menu = True
示例#23
0
 def __init__(self, app):
     super().__init__(app)
     self.menu_text = "You can modify any setting in the list below:"
     self.menu_item_text = "Config File Settings"
     self.menu_item_emoji = EMOJIS.get("GEAR", "")
示例#24
0
 def __init__(self, app):
     super().__init__(app)
     self.menu_text = "Select the type of error to investigate:"
     self.menu_item_text = "Investigate Failures"
     self.menu_item_emoji = EMOJIS.get("FLASHLIGHT")
示例#25
0
def _get_menu_item_emoji(use_numbers, num=None):
    if use_numbers and num:
        return MENU_NUMBERS.get(num, str(num))
    return EMOJIS.get("BLUE_DIAMOND")
示例#26
0
 def __init__(self, app):
     super().__init__(app)
     self.menu_text = "You can modify any setting in the list below:"
     self.menu_item_text = "Environment Variables"
     self.menu_item_emoji = EMOJIS.get("SPIRAL", "")
示例#27
0
 def __init__(self, app):
     # TODO: Add Admin Task menu item to edit season dates and add new seasons
     super().__init__(app)
     self.menu_text = "Select a task from the list:"
     self.menu_item_text = "Tasks/Admin"
     self.menu_item_emoji = EMOJIS.get("PAGER", "")
示例#28
0
 def __init__(self, app):
     super().__init__(app)
     self.menu_text = "You can view/edit Config File settings or Env. Variable settings:"
     self.menu_item_text = "Settings"
     self.menu_item_emoji = EMOJIS.get("TOOLS", "")