Revision 36fa6ffb kamaki/cli/utils/__init__.py
b/kamaki/cli/utils/__init__.py | ||
---|---|---|
434 | 434 |
return terms |
435 | 435 |
|
436 | 436 |
|
437 |
def ask_user(msg, true_resp=('y', ), out=stdout, user_in=stdin):
|
|
437 |
def ask_user(msg, true_resp=('y', ), **kwargs):
|
|
438 | 438 |
"""Print msg and read user response |
439 | 439 |
|
440 | 440 |
:param true_resp: (tuple of chars) |
... | ... | |
443 | 443 |
""" |
444 | 444 |
yep = ', '.join(true_resp) |
445 | 445 |
nope = '<not %s>' % yep if 'n' in true_resp or 'N' in true_resp else 'N' |
446 |
out.write('%s [%s/%s]: ' % (msg, yep, nope)) |
|
447 |
user_response = user_in.readline() |
|
446 |
user_response = raw_input('%s [%s/%s]: ' % (msg, yep, nope)) |
|
448 | 447 |
return user_response[0].lower() in [s.lower() for s in true_resp] |
449 | 448 |
|
450 | 449 |
|
Also available in: Unified diff