diff --git a/IPython/frontend/kernelmixinapp.py b/IPython/frontend/kernelmixinapp.py index d7f7ab7..ba51c69 100644 --- a/IPython/frontend/kernelmixinapp.py +++ b/IPython/frontend/kernelmixinapp.py @@ -198,8 +198,6 @@ class IPythonMixinConsoleApp(Configurable): # Scrub frontend-specific flags swallow_next = False was_flag = False - # copy again, in case some aliases have the same name as a flag - # argv = list(self.kernel_argv) for a in argv: if swallow_next: swallow_next = False diff --git a/IPython/frontend/qt/console/qtconsoleapp.py b/IPython/frontend/qt/console/qtconsoleapp.py index 4e613ca..32d6463 100644 --- a/IPython/frontend/qt/console/qtconsoleapp.py +++ b/IPython/frontend/qt/console/qtconsoleapp.py @@ -50,7 +50,7 @@ from IPython.zmq.session import Session, default_secure from IPython.zmq.zmqshell import ZMQInteractiveShell from IPython.frontend.kernelmixinapp import ( - IPythonMixinConsoleApp, app_aliases, app_flags + IPythonMixinConsoleApp, app_aliases, app_flags, flags, aliases ) #----------------------------------------------------------------------------- @@ -72,8 +72,8 @@ ipython qtconsole --pylab=inline # start with pylab in inline plotting mode # Aliases and Flags #----------------------------------------------------------------------------- -# XXX: the app_flags should really be flags from the mixin -flags = dict(app_flags) +# start with copy of flags +flags = dict(flags) qt_flags = { 'pure' : ({'IPythonQtConsoleApp' : {'pure' : True}}, "Use a pure Python kernel instead of an IPython kernel."), @@ -85,10 +85,13 @@ qt_flags.update(boolean_flag( "use a GUI widget for tab completion", "use plaintext output for completion" )) +# and app_flags from the Console Mixin +qt_flags.update(app_flags) +# add frontend flags to the full set flags.update(qt_flags) -aliases = dict(app_aliases) - +# start with copy of front&backend aliases list +aliases = dict(aliases) qt_aliases = dict( style = 'IPythonWidget.syntax_style', @@ -98,8 +101,17 @@ qt_aliases = dict( editor = 'IPythonWidget.editor', paging = 'ConsoleWidget.paging', ) +# and app_aliases from the Console Mixin +qt_aliases.update(app_aliases) +# add frontend aliases to the full set aliases.update(qt_aliases) +# get flags&aliases into sets, and remove a couple that +# shouldn't be scrubbed from backend flags: +qt_aliases = set(qt_aliases.keys()) +qt_aliases.remove('colors') +qt_flags = set(qt_flags.keys()) + #----------------------------------------------------------------------------- # Classes #----------------------------------------------------------------------------- @@ -157,11 +169,8 @@ class IPythonQtConsoleApp(BaseIPythonApplication, IPythonMixinConsoleApp): def parse_command_line(self, argv=None): super(IPythonQtConsoleApp, self).parse_command_line(argv) - IPythonMixinConsoleApp.parse_command_line(self,argv) self.swallow_args(qt_aliases,qt_flags,argv=argv) - - def new_frontend_master(self): """ Create and return new frontend attached to new kernel, launched on localhost. diff --git a/IPython/frontend/terminal/ipapp.py b/IPython/frontend/terminal/ipapp.py index d82a059..54f5332 100755 --- a/IPython/frontend/terminal/ipapp.py +++ b/IPython/frontend/terminal/ipapp.py @@ -115,7 +115,8 @@ class IPAppCrashHandler(CrashHandler): #----------------------------------------------------------------------------- flags = dict(base_flags) flags.update(shell_flags) -addflag = lambda *args: flags.update(boolean_flag(*args)) +frontend_flags = {} +addflag = lambda *args: frontend_flags.update(boolean_flag(*args)) addflag('autoedit-syntax', 'TerminalInteractiveShell.autoedit_syntax', 'Turn on auto editing of files with syntax errors.', 'Turn off auto editing of files with syntax errors.' @@ -146,7 +147,7 @@ classic_config.InteractiveShell.separate_out2 = '' classic_config.InteractiveShell.colors = 'NoColor' classic_config.InteractiveShell.xmode = 'Plain' -flags['classic']=( +frontend_flags['classic']=( classic_config, "Gives IPython a similar feel to the classic Python prompt." ) @@ -156,21 +157,22 @@ flags['classic']=( # help="Start logging to the default log file (./ipython_log.py).") # # # quick is harder to implement -flags['quick']=( +frontend_flags['quick']=( {'TerminalIPythonApp' : {'quick' : True}}, "Enable quick startup with no config files." ) -flags['i'] = ( +frontend_flags['i'] = ( {'TerminalIPythonApp' : {'force_interact' : True}}, """If running code from the command line, become interactive afterwards. Note: can also be given simply as '-i.'""" ) -flags['pylab'] = ( +frontend_flags['pylab'] = ( {'TerminalIPythonApp' : {'pylab' : 'auto'}}, """Pre-load matplotlib and numpy for interactive use with the default matplotlib backend.""" ) +flags.update(frontend_flags) aliases = dict(base_aliases) aliases.update(shell_aliases) diff --git a/IPython/frontend/zmqterminal/app.py b/IPython/frontend/zmqterminal/app.py index df213cc..c9407b4 100644 --- a/IPython/frontend/zmqterminal/app.py +++ b/IPython/frontend/zmqterminal/app.py @@ -17,7 +17,7 @@ import signal import sys import time -from IPython.frontend.terminal.ipapp import TerminalIPythonApp +from IPython.frontend.terminal.ipapp import TerminalIPythonApp, frontend_flags as term_flags from IPython.utils.traitlets import ( Dict, List, Unicode, Int, CaselessStrEnum, CBool, Any @@ -26,7 +26,7 @@ from IPython.zmq.ipkernel import IPKernelApp from IPython.zmq.session import Session, default_secure from IPython.zmq.zmqshell import ZMQInteractiveShell from IPython.frontend.kernelmixinapp import ( - IPythonMixinConsoleApp, app_aliases, app_flags + IPythonMixinConsoleApp, app_aliases, app_flags, aliases, app_aliases, flags ) from IPython.frontend.zmqterminal.interactiveshell import ZMQTerminalInteractiveShell @@ -44,18 +44,31 @@ ipython console --existing # connect to an existing ipython session # Flags and Aliases #----------------------------------------------------------------------------- -# XXX: the app_flags should really be flags from the mixin -flags = dict(app_flags) -frontend_flags = { } +# copy flags from mixin: +flags = dict(flags) +# start with mixin frontend flags: +frontend_flags = dict(app_flags) +# add TerminalIPApp flags: +frontend_flags.update(term_flags) +# pylab is not frontend-specific in two-process IPython +frontend_flags.pop('pylab') +# disable quick startup, as it won't propagate to the kernel anyway +frontend_flags.pop('quick') +# update full dict with frontend flags: flags.update(frontend_flags) -frontend_flags = frontend_flags.keys() - -aliases = dict(app_aliases) +# copy flags from mixin +aliases = dict(aliases) +# start with mixin frontend flags +frontend_aliases = dict(app_aliases) +# load updated frontend flags into full dict +aliases.update(frontend_aliases) -frontend_aliases = dict() +# get flags&aliases into sets, and remove a couple that +# shouldn't be scrubbed from backend flags: +frontend_aliases = set(frontend_aliases.keys()) +frontend_flags = set(frontend_flags.keys()) -aliases.update(frontend_aliases) #----------------------------------------------------------------------------- # Classes @@ -63,7 +76,7 @@ aliases.update(frontend_aliases) class ZMQTerminalIPythonApp(TerminalIPythonApp, IPythonMixinConsoleApp): - name = "ipython console" + name = "ipython-console" """Start a terminal frontend to the IPython zmq kernel.""" description = """ @@ -83,13 +96,13 @@ class ZMQTerminalIPythonApp(TerminalIPythonApp, IPythonMixinConsoleApp): """ examples = _examples - classes = List([IPKernelApp, ZMQTerminalInteractiveShell]) + classes = List([IPKernelApp, ZMQTerminalInteractiveShell, Session]) flags = Dict(flags) aliases = Dict(aliases) subcommands = Dict() + def parse_command_line(self, argv=None): super(ZMQTerminalIPythonApp, self).parse_command_line(argv) - IPythonMixinConsoleApp.parse_command_line(self,argv) self.swallow_args(frontend_aliases,frontend_flags,argv=argv) def init_shell(self):