From 9a6c8976450c51777c2ac9fa6e45686d51693d9b 2006-06-07 16:56:50 From: vivainio Date: 2006-06-07 16:56:50 Subject: [PATCH] added 'quiet' option --- diff --git a/IPython/Magic.py b/IPython/Magic.py index d70235b..3f111ec 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 1351 2006-06-05 13:43:18Z vivainio $""" +$Id: Magic.py 1355 2006-06-07 16:56:50Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -973,9 +973,9 @@ Currently the magic system has the following functions:\n""" Input/Output history are left around in case you need them.""" - ans = raw_input( - "Once deleted, variables cannot be recovered. Proceed (y/n)? ") - if not ans.lower() == 'y': + ans = self.shell.ask_yes_no( + "Once deleted, variables cannot be recovered. Proceed (y/[n])? ") + if not ans: print 'Nothing done.' return user_ns = self.shell.user_ns diff --git a/IPython/iplib.py b/IPython/iplib.py index a5d5070..4368d0c 100644 --- a/IPython/iplib.py +++ b/IPython/iplib.py @@ -6,7 +6,7 @@ Requires Python 2.3 or newer. This file contains all the classes and helper functions specific to IPython. -$Id: iplib.py 1350 2006-06-04 14:06:06Z fperez $ +$Id: iplib.py 1355 2006-06-07 16:56:50Z vivainio $ """ #***************************************************************************** @@ -1231,6 +1231,11 @@ want to merge them back into the new files.""" % locals() # Configure auto-indent for all platforms self.set_autoindent(self.rc.autoindent) + def ask_yes_no(self,prompt,default=True): + if self.rc.quiet: + return True + return ask_yes_no(prompt,default) + def _should_recompile(self,e): """Utility routine for edit_syntax_error""" @@ -1241,7 +1246,7 @@ want to merge them back into the new files.""" % locals() return False try: if (self.rc.autoedit_syntax and - not ask_yes_no('Return to editor to correct syntax error? ' + not self.ask_yes_no('Return to editor to correct syntax error? ' '[Y/n] ','y')): return False except EOFError: @@ -2207,7 +2212,7 @@ want to merge them back into the new files.""" % locals() This method sets the exit_now attribute.""" if self.rc.confirm_exit: - if ask_yes_no('Do you really want to exit ([y]/n)?','y'): + if self.ask_yes_no('Do you really want to exit ([y]/n)?','y'): self.exit_now = True else: self.exit_now = True diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index 4e6154c..570edc4 100644 --- a/IPython/ipmaker.py +++ b/IPython/ipmaker.py @@ -6,7 +6,7 @@ Requires Python 2.1 or better. This file contains the main make_IPython() starter function. -$Id: ipmaker.py 1347 2006-06-04 00:42:44Z fperez $""" +$Id: ipmaker.py 1355 2006-06-07 16:56:50Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -208,6 +208,7 @@ object? -> Details about 'object'. ?object also works, ?? prints more. prompt_in2 = ' .\\D.: ', prompt_out = 'Out[\\#]: ', prompts_pad_left = 1, + quiet = 0, quick = 0, readline = 1, readline_merge_completions = 1, diff --git a/doc/ChangeLog b/doc/ChangeLog index 0b02e1e..82af9eb 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2006-06-07 Ville Vainio + + * iplib.py,Magic.py, ipmaker.py (magic_rehashx): + Confirmation prompts can be supressed by 'quiet' option. + _ip.options.quiet = 1 means "assume yes for all yes/no queries". + 2006-06-06 Fernando Perez * IPython/Release.py (version): Made 0.7.2 final for release. @@ -6,10 +12,10 @@ 2006-06-05 Ville Vainio * Magic.py (magic_rehashx): Honor no_alias list earlier in - %rehashx, to avoid clobbering builtins in ipy_profile_sh.py + %rehashx, to avoid clobbering builtins in ipy_profile_sh.py - * upgrade_dir.py: try import 'path' module a bit harder - (for %upgrade)A + * upgrade_dir.py: try import 'path' module a bit harder + (for %upgrade) 2006-06-03 Fernando Perez