mirror of
https://github.com/samba-team/samba.git
synced 2025-07-23 20:59:10 +03:00
s4-pycommon: allow an optional 'all' choice for confirm dialogs
when asking the user to confirm an action, allow for an 'all' choice, which will be used to allow the user to confirm all future requests of the same type
This commit is contained in:
@ -18,7 +18,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
def confirm(msg, forced = False):
|
||||
def confirm(msg, forced = False, allow_all=False):
|
||||
"""confirm an action with the user
|
||||
:param msg: A string to print to the user
|
||||
:param forced: Are the answer forced
|
||||
@ -27,6 +27,12 @@ def confirm(msg, forced = False):
|
||||
print("%s [YES]" % msg)
|
||||
return True
|
||||
|
||||
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']
|
||||
|
||||
|
Reference in New Issue
Block a user