Commit 3877a286 authored by Matt Traudt's avatar Matt Traudt
Browse files

Modify query_yes_no to be easier to test cleanly

parent eae15aa2
......@@ -19,12 +19,15 @@ def query_yes_no(question, default='yes'):
prompt = ' [y/N] '
else:
raise ValueError('invalid default answer: "%s"' % default)
prompt = question + prompt
first_loop = True
while True:
print(question + prompt, end='')
choice = input().lower()
choice = input(prompt).lower()
if default is not None and choice == '':
return valid[default]
elif choice in valid:
return valid[choice]
else:
print('Please respond with "yes" or "no" (or "y" or "n").\n')
elif first_loop:
prompt = 'Please respond with "yes" or "no" (or y or n).\n' +\
prompt
first_loop = False
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment