def _abort_helpers() -> List[ChoiceHelper]: if no_style: style = None skip_mnemonic = "[s]" quit_mnemonic = "[q]" else: style = "dark" skip_mnemonic = "s" quit_mnemonic = "q" return [ ChoiceHelper(MnamerSkipException, "skip", style, skip_mnemonic), ChoiceHelper(MnamerAbortException, "quit", style, quit_mnemonic), ]
def subtitle_prompt() -> Metadata: msg("select language") choices = [ChoiceHelper(language, language.name) for language in Language.all()] selector = SelectOne(choices + _abort_helpers(), **_chars()) choice = selector.prompt() if choice in (MnamerAbortException, MnamerSkipException): raise choice else: return choice
def metadata_guess( metadata: Metadata, ) -> Optional[Metadata]: # pragma: no cover """Prompts user to confirm a single match.""" label = str(metadata) if no_style: label += " (best guess)" else: label += style_format(" (best guess)", "blue") option = ChoiceHelper(metadata, label) selector = SelectOne([option] + _abort_helpers(), **_chars()) choice = selector.prompt() if choice in (MnamerAbortException, MnamerSkipException): raise choice else: return choice