##// END OF EJS Templates
support `-pylab` flag with deprecation warning...
MinRK -
Show More
@@ -45,6 +45,7 b' from IPython.core.shellapp import ('
45 )
45 )
46 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
46 from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
47 from IPython.lib import inputhook
47 from IPython.lib import inputhook
48 from IPython.utils import warn
48 from IPython.utils.path import get_ipython_dir, check_for_old_config
49 from IPython.utils.path import get_ipython_dir, check_for_old_config
49 from IPython.utils.traitlets import (
50 from IPython.utils.traitlets import (
50 Bool, Dict, CaselessStrEnum
51 Bool, Dict, CaselessStrEnum
@@ -254,6 +255,32 b' class TerminalIPythonApp(BaseIPythonApplication, InteractiveShellApp):'
254 interact=Bool(True)
255 interact=Bool(True)
255
256
256
257
258 def parse_command_line(self, argv=None):
259 """override to allow old '-pylab' flag with deprecation warning"""
260 argv = sys.argv[1:] if argv is None else argv
261
262 try:
263 idx = argv.index('-pylab')
264 except ValueError:
265 # `-pylab` not given, proceed as normal
266 pass
267 else:
268 # deprecated `-pylab` given,
269 # warn and transform into current syntax
270 argv = list(argv) # copy, don't clobber
271 warn.warn("`-pylab` flag has been deprecated.\n"
272 " Use `--pylab` instead, or `pylab=foo` to specify a backend.")
273 sub = '--pylab'
274 if len(argv) > idx+1:
275 # check for gui arg, as in '-pylab qt'
276 gui = argv[idx+1]
277 if gui in ('wx', 'qt', 'qt4', 'gtk', 'auto'):
278 sub = 'pylab='+gui
279 argv.pop(idx+1)
280 argv[idx] = sub
281
282 return super(TerminalIPythonApp, self).parse_command_line(argv)
283
257 def initialize(self, argv=None):
284 def initialize(self, argv=None):
258 """Do actions after construct, but before starting the app."""
285 """Do actions after construct, but before starting the app."""
259 super(TerminalIPythonApp, self).initialize(argv)
286 super(TerminalIPythonApp, self).initialize(argv)
General Comments 0
You need to be logged in to leave comments. Login now