summaryrefslogtreecommitdiffstats
path: root/askbot/utils
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-18 21:18:49 -0300
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2012-11-18 21:18:49 -0300
commite0dcb50e48b25f7fe641d54b5338e09486b7157e (patch)
tree1f291181f4dc7885b47b1302ebc43cfd471ecef8 /askbot/utils
parentbf3e433665b94907057d6c8914077c94ed92b638 (diff)
downloadaskbot-e0dcb50e48b25f7fe641d54b5338e09486b7157e.tar.gz
askbot-e0dcb50e48b25f7fe641d54b5338e09486b7157e.tar.bz2
askbot-e0dcb50e48b25f7fe641d54b5338e09486b7157e.zip
improved askbot-setup script
Diffstat (limited to 'askbot/utils')
-rw-r--r--askbot/utils/console.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/askbot/utils/console.py b/askbot/utils/console.py
index 0c27cd23..644a7f21 100644
--- a/askbot/utils/console.py
+++ b/askbot/utils/console.py
@@ -24,7 +24,9 @@ def choice_dialog(prompt_phrase, choices = None, invalid_phrase = None):
assert(hasattr(choices, '__iter__'))
assert(not isinstance(choices, basestring))
while 1:
- response = raw_input('\n%s (type %s): ' % (prompt_phrase, '/'.join(choices)))
+ response = raw_input(
+ '\n%s (type %s)\n> ' % (prompt_phrase, '/'.join(choices))
+ )
if response in choices:
return response
elif invalid_phrase != None:
@@ -32,6 +34,23 @@ def choice_dialog(prompt_phrase, choices = None, invalid_phrase = None):
print invalid_phrase % {'opt_string': opt_string}
time.sleep(1)
+def simple_dialog(prompt_phrase, required=False):
+ """asks user to enter a string, if `required` is True,
+ will repeat question until non-empty input is given
+ """
+ while 1:
+
+ if required:
+ prompt_phrase += ' (required)'
+
+ response = raw_input(prompt_phrase + '\n> ').strip()
+
+ if response or required is False:
+ return response
+
+ time.sleep(1)
+
+
def open_new_file(prompt_phrase, extension = '', hint = None):
"""will ask for a file name to be typed
by user into the console path to the file can be