@@ -106,8 +106,7 @@ def prompt_yes_no(name, default=True):
106106 return prompt_bool (name , default = default )
107107
108108
109- def prompt_choices (name , choices , default = None , resolve = ascii_lowercase ,
110- no_choice = ('none' ,)):
109+ def prompt_choices (name , choices , default = None , no_choice = ('none' ,)):
111110 """Return user input from command line from set of provided choices.
112111
113112 :param name: prompt text
@@ -123,7 +122,7 @@ def prompt_choices(name, choices, default=None, resolve=ascii_lowercase,
123122 options = []
124123
125124 for choice in choices :
126- if isinstance (choice , basestring ) :
125+ if type (choice ) is str :
127126 options .append (choice )
128127 else :
129128 options .append ("%s [%s]" % (choice [1 ], choice [0 ]))
@@ -134,7 +133,7 @@ def prompt_choices(name, choices, default=None, resolve=ascii_lowercase,
134133 rv = prompt (name + ' - (%s)' % ', ' .join (options ), default )
135134 if not rv :
136135 return default
137- rv = resolve ( rv )
136+ rv = rv . lower ( )
138137 if rv in no_choice :
139138 return None
140139 if rv in _choices :
@@ -966,7 +965,9 @@ def main():
966965 )
967966
968967 try :
969- if args .callback is command_load :
968+ if not hasattr (args , 'callback' ):
969+ parser .print_help ()
970+ elif args .callback is command_load :
970971 command_load (args )
971972 elif args .callback is command_convert :
972973 command_convert (args )
@@ -980,7 +981,5 @@ def main():
980981 command_attach_session (args )
981982 elif args .callback is command_kill_session :
982983 command_kill_session (args )
983- else :
984- parser .print_help ()
985984 except KeyboardInterrupt :
986985 pass
0 commit comments