diff options
| author | Scott Gasch <[email protected]> | 2021-09-15 09:32:08 -0700 |
|---|---|---|
| committer | Scott Gasch <[email protected]> | 2021-09-15 09:32:08 -0700 |
| commit | 4c315e387f18010ba0b5661744ad3c792f21d2d1 (patch) | |
| tree | a5657340bea356aa3aaf2c24b7f2be98bb4bc302 /input_utils.py | |
| parent | 83c1e0d04fe2e78963c8b508e8b7d0ae03bfcb16 (diff) | |
Adding doctests. Also added a logging filter.
Diffstat (limited to 'input_utils.py')
| -rw-r--r-- | input_utils.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/input_utils.py b/input_utils.py index 648ee30..153641b 100644 --- a/input_utils.py +++ b/input_utils.py @@ -17,6 +17,8 @@ def single_keystroke_response( default_response: str = None, timeout_seconds: int = None, ) -> str: + """Get a single keystroke response to a prompt.""" + def _handle_timeout(signum, frame) -> None: raise exceptions.TimeoutError() @@ -56,12 +58,16 @@ def single_keystroke_response( def yn_response(prompt: str = None, *, timeout_seconds=None) -> str: + """Get a Y/N response to a prompt.""" + return single_keystroke_response( ["y", "n", "Y", "N"], prompt=prompt, timeout_seconds=timeout_seconds ).lower() def keystroke_helper() -> None: + """Misc util to watch keystrokes and report what they were.""" + print("Watching for keystrokes; ^C to quit.") while True: key = readchar.readkey() |
