MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / user_choice

Function user_choice

keepercommander/commands/base.py:240–264  ·  view source on GitHub ↗
(question, choice, default='', show_choice=True, multi_choice=False)

Source from the content-addressed store, hash-verified

238
239
240def user_choice(question, choice, default='', show_choice=True, multi_choice=False):
241 choices = [ch.lower() if ch.upper() == default.upper() else ch.lower() for ch in choice]
242
243 result = ''
244 while True:
245 pr = question
246 if show_choice:
247 pr = pr + ' [' + '/'.join(choices) + ']'
248
249 pr = pr + ': '
250 result = input(pr)
251
252 if len(result) == 0:
253 return default
254
255 if multi_choice:
256 s1 = set([x.lower() for x in choices])
257 s2 = set([x.lower() for x in result])
258 if s2 < s1:
259 return ''.join(s2)
260 pass
261 elif any(map(lambda x: x.upper() == result.upper(), choices)):
262 return result
263
264 logging.error('Error: invalid input')
265
266
267def raise_parse_exception(m):

Callers 15

_resolve_contactMethod · 0.90
executeMethod · 0.90
executeMethod · 0.85
executeMethod · 0.85
remove_v5_appMethod · 0.85
remove_all_clientsMethod · 0.85
remove_clientMethod · 0.85
revoke_clientMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85
executeMethod · 0.85

Calls 1

errorMethod · 0.45

Tested by

no test coverage detected