ui.cli: Don't record EOF or blank entries as answers
authorW. Trevor King <wking@tremily.us>
Fri, 22 Mar 2013 15:27:45 +0000 (11:27 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 22 Mar 2013 15:27:45 +0000 (11:27 -0400)
If the user closes stdin, don't check and see if 'EOF' is an allowed
answer, just exit the QuestionCommandLine loop.  Don't try to process
blank entries either, just re-ask the question.

quizzer/ui/cli.py

index cbfa16df3be4cef7a8e968161e191ce66361c642..14ae67f97242254d4d70b7b86d20fcb73c2360ab 100644 (file)
@@ -122,6 +122,10 @@ class QuestionCommandLine (_cmd.Cmd):
             answer = self.answers[0]
         else:
             answer = ''
+        if answer == 'EOF':
+            return True  # quit
+        if answer == '':
+            return
         kwargs = {}
         if self._tempdir:
             kwargs['tempdir'] = self._tempdir