Adding doctests. Also added a logging filter.
[python_utils.git] / input_utils.py
index 648ee301639ec876750ebdd2b5d98e0d01603eaf..153641b135cfd7debb9b4e20e60ca400316c4dca 100644 (file)
@@ -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()