Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions IPython/frontend/terminal/ipapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down