mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
s4-pycommon: support 'none' as an option in confirm
this allows the user to ask for none of the changes of this type Pair-Programmed-With: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
c6985f1e7e
commit
bce1be36dc
@ -27,13 +27,26 @@ def confirm(msg, forced = False, allow_all=False):
|
||||
print("%s [YES]" % msg)
|
||||
return True
|
||||
|
||||
mapping = {
|
||||
'Y': True,
|
||||
'YES': True,
|
||||
'': False,
|
||||
'N': False,
|
||||
'NO': False,
|
||||
}
|
||||
|
||||
prompt = '[y/N]'
|
||||
|
||||
if allow_all:
|
||||
v = raw_input(msg + ' [y/N/all] ')
|
||||
if v.upper() == 'ALL':
|
||||
return "ALL"
|
||||
return v.upper() in ['Y', 'YES']
|
||||
else:
|
||||
v = raw_input(msg + ' [y/N] ')
|
||||
return v.upper() in ['Y', 'YES']
|
||||
mapping['ALL'] = 'ALL'
|
||||
mapping['NONE'] = 'NONE'
|
||||
prompt = '[y/N/all/none]'
|
||||
|
||||
while True:
|
||||
v = raw_input(msg + ' %s ' % prompt)
|
||||
v = v.upper()
|
||||
if v in mapping:
|
||||
return mapping[v]
|
||||
print("Unknown response '%s'" % v)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user