diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-07-05 12:38:31 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-07-05 07:10:03 +0200 |
commit | c9497bd77fd1e3f69b979a1799b7903b07972304 (patch) | |
tree | 930c01b74d2d96acde8ddc0c1f4883a41a5f92da /source4 | |
parent | 28dbd8bbc174f5417b9dccea38f296e385f2c378 (diff) | |
download | samba-c9497bd77fd1e3f69b979a1799b7903b07972304.tar.gz samba-c9497bd77fd1e3f69b979a1799b7903b07972304.tar.bz2 samba-c9497bd77fd1e3f69b979a1799b7903b07972304.zip |
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
Diffstat (limited to 'source4')
-rw-r--r-- | source4/scripting/python/samba/common.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/source4/scripting/python/samba/common.py b/source4/scripting/python/samba/common.py index a2a4962797..ebb3f88733 100644 --- a/source4/scripting/python/samba/common.py +++ b/source4/scripting/python/samba/common.py @@ -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,7 +27,13 @@ def confirm(msg, forced = False): print("%s [YES]" % msg) return True - v = raw_input(msg + ' [y/N] ') - return v.upper() in ['Y', 'YES'] + 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'] |