Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_ctrl_d_abort(self, *m):
with InputContext(readchar.key.CTRL_D):
with self.assertRaises(KeyboardInterrupt):
cutie.prompt_yes_or_no("")
def test_ctrl_d_abort_with_input(self, *m):
with InputContext(readchar.key.UP, readchar.key.CTRL_D):
with self.assertRaises(KeyboardInterrupt):
cutie.prompt_yes_or_no("")
def test_keyboard_interrupt_ctrl_d_no_input(self, *m):
with InputContext(readchar.key.CTRL_D):
with self.assertRaises(KeyboardInterrupt):
cutie.select(["foo"])
def test_keyboard_interrupt_ctrl_d_selected(self, *m):
with InputContext(readchar.key.DOWN, readchar.key.CTRL_D):
with self.assertRaises(KeyboardInterrupt):
cutie.select(["foo"], selected_index=0)
init()
class DefaultKeys:
"""List of default keybindings.
Attributes:
interrupt(List[str]): Keys that cause a keyboard interrupt.
select(List[str]): Keys that trigger list element selection.
confirm(List[str]): Keys that trigger list confirmation.
delete(List[str]): Keys that trigger character deletion.
down(List[str]): Keys that select the element below.
up(List[str]): Keys that select the element above.
"""
interrupt: List[str] = [readchar.key.CTRL_C, readchar.key.CTRL_D]
select: List[str] = [readchar.key.SPACE]
confirm: List[str] = [readchar.key.ENTER]
delete: List[str] = [readchar.key.BACKSPACE]
down: List[str] = [readchar.key.DOWN, 'j']
up: List[str] = [readchar.key.UP, 'k']
def get_number(
prompt: str,
min_value: Optional[float] = None,
max_value: Optional[float] = None,
allow_float: bool = True) -> float:
"""Get a number from user input.
If an invalid number is entered the user will be prompted again.
Args: