Skip to content
Browse files

support `-pylab` flag with deprecation warning

closes gh-540
  • Loading branch information...
1 parent 0e4fe98 commit b6abd4dcc155c9ddd1666e03731d4a78d96e5149 @minrk minrk committed Jun 24, 2011
Showing with 27 additions and 0 deletions.
  1. +27 −0 IPython/frontend/terminal/ipapp.py
View
27 IPython/frontend/terminal/ipapp.py
@@ -45,6 +45,7 @@
)
from IPython.frontend.terminal.interactiveshell import TerminalInteractiveShell
from IPython.lib import inputhook
+from IPython.utils import warn
from IPython.utils.path import get_ipython_dir, check_for_old_config
from IPython.utils.traitlets import (
Bool, Dict, CaselessStrEnum
@@ -254,6 +255,32 @@ def _file_to_run_changed(self, name, old, new):
interact=Bool(True)
+ def parse_command_line(self, argv=None):
+ """override to allow old '-pylab' flag with deprecation warning"""
+ argv = sys.argv[1:] if argv is None else argv
+
+ try:
+ idx = argv.index('-pylab')
+ except ValueError:
+ # `-pylab` not given, proceed as normal
+ pass
+ else:
+ # deprecated `-pylab` given,
+ # warn and transform into current syntax
+ argv = list(argv) # copy, don't clobber
+ warn.warn("`-pylab` flag has been deprecated.\n"
+ " Use `--pylab` instead, or `pylab=foo` to specify a backend.")
+ sub = '--pylab'
+ if len(argv) > idx+1:
+ # check for gui arg, as in '-pylab qt'
+ gui = argv[idx+1]
+ if gui in ('wx', 'qt', 'qt4', 'gtk', 'auto'):
+ sub = 'pylab='+gui
+ argv.pop(idx+1)
+ argv[idx] = sub
+
+ return super(TerminalIPythonApp, self).parse_command_line(argv)
+
def initialize(self, argv=None):
"""Do actions after construct, but before starting the app."""
super(TerminalIPythonApp, self).initialize(argv)

0 comments on commit b6abd4d

Please sign in to comment.
Something went wrong with that request. Please try again.