From 087a201128982205c213bc4ec31bbe4ec5f0e430 2011-06-20 23:40:21 From: MinRK Date: 2011-06-20 23:40:21 Subject: [PATCH] code updates per review of PR #454 --- diff --git a/IPython/config/loader.py b/IPython/config/loader.py index 7ef6534..92df8c6 100644 --- a/IPython/config/loader.py +++ b/IPython/config/loader.py @@ -350,15 +350,27 @@ class KeyValueConfigLoader(CommandLineConfigLoader): >>> cl.load_config(["foo='bar'","A.name='brian'","B.number=0"]) {'A': {'name': 'brian'}, 'B': {'number': 0}, 'foo': 'bar'} """ + self.clear() if argv is None: argv = sys.argv[1:] self.argv = argv self.aliases = aliases or {} self.flags = flags or {} + + + def clear(self): + super(KeyValueConfigLoader, self).clear() + self.extra_args = [] + def load_config(self, argv=None, aliases=None, flags=None): """Parse the configuration and generate the Config object. - + + After loading, any arguments that are not key-value or + flags will be stored in self.extra_args - a list of + unparsed command-line arguments. This is used for + arguments such as input files or subcommands. + Parameters ---------- argv : list, optional @@ -384,8 +396,6 @@ class KeyValueConfigLoader(CommandLineConfigLoader): if flags is None: flags = self.flags - self.extra_args = [] - for item in argv: if kv_pattern.match(item): lhs,rhs = item.split('=',1) diff --git a/IPython/core/shellapp.py b/IPython/core/shellapp.py index a8fe0fc..803910f 100755 --- a/IPython/core/shellapp.py +++ b/IPython/core/shellapp.py @@ -28,6 +28,7 @@ import sys from IPython.config.application import boolean_flag from IPython.config.configurable import Configurable +from IPython.config.loader import Config from IPython.utils.path import filefind from IPython.utils.traitlets import Unicode, Instance, List @@ -63,7 +64,7 @@ addflag('color-info', 'InteractiveShell.color_info', it and turn it on permanently in your ipython_config.py file if it works for you. Test it and turn it on permanently if it works with your system. The magic function %%color_info allows you to toggle this - inter- actively for testing.""", + interactively for testing.""", "Disable using colors for info related things." ) addflag('deep-reload', 'InteractiveShell.deep_reload', @@ -78,6 +79,13 @@ addflag('deep-reload', 'InteractiveShell.deep_reload', dreload()].""", "Disable deep (recursive) reloading by default." ) +nosep_config = Config() +nosep_config.InteractiveShell.separate_in = '' +nosep_config.InteractiveShell.separate_out = '' +nosep_config.InteractiveShell.separate_out2 = '' + +shell_flags['nosep']=(nosep_config, "Eliminate all spacing between prompts.") + # it's possible we don't want short aliases for *all* of these: shell_aliases = dict( @@ -86,13 +94,6 @@ shell_aliases = dict( colors='InteractiveShell.colors', logfile='InteractiveShell.logfile', log_append='InteractiveShell.logappend', - pi1='InteractiveShell.prompt_in1', - pi2='InteractiveShell.prompt_in1', - po='InteractiveShell.prompt_out', - si='InteractiveShell.separate_in', - so='InteractiveShell.separate_out', - so2='InteractiveShell.separate_out2', - xmode='InteractiveShell.xmode', c='InteractiveShellApp.code_to_run', ext='InteractiveShellApp.extra_extension', ) diff --git a/IPython/frontend/qt/console/console_widget.py b/IPython/frontend/qt/console/console_widget.py index c43e6bb..f343045 100644 --- a/IPython/frontend/qt/console/console_widget.py +++ b/IPython/frontend/qt/console/console_widget.py @@ -79,13 +79,14 @@ class ConsoleWidget(Configurable, QtGui.QWidget): default_value='inside', config=True, help=""" The type of paging to use. Valid values are: + 'inside' : The widget pages like a traditional terminal. 'hsplit' : When paging is requested, the widget is split - : horizontally. The top pane contains the console, and the - : bottom pane contains the paged text. + horizontally. The top pane contains the console, and the + bottom pane contains the paged text. 'vsplit' : Similar to 'hsplit', except that a vertical splitter used. 'custom' : No action is taken by the widget beyond emitting a - : 'custom_page_requested(str)' signal. + 'custom_page_requested(str)' signal. 'none' : The text is written directly to the console. """) diff --git a/IPython/frontend/qt/console/ipythonqt.py b/IPython/frontend/qt/console/ipythonqt.py index 04d413c..8a567c2 100644 --- a/IPython/frontend/qt/console/ipythonqt.py +++ b/IPython/frontend/qt/console/ipythonqt.py @@ -1,4 +1,15 @@ """ A minimal application using the Qt console-style IPython frontend. + +This is not a complete console app, as subprocess will not be able to receive +input, there is no real readline support, among other limitations. + +Authors: + +* Evan Patterson +* Min RK +* Erik Tollerud +* Fernando Perez + """ #----------------------------------------------------------------------------- @@ -201,20 +212,25 @@ aliases.update(dict( colors = 'ZMQInteractiveShell.colors', editor = 'IPythonWidget.editor', - pi = 'IPythonWidget.in_prompt', - po = 'IPythonWidget.out_prompt', - si = 'IPythonWidget.input_sep', - so = 'IPythonWidget.output_sep', - so2 = 'IPythonWidget.output_sep2', )) #----------------------------------------------------------------------------- # IPythonQtConsole #----------------------------------------------------------------------------- - class IPythonQtConsoleApp(BaseIPythonApplication): name = 'ipython-qtconsole' default_config_file_name='ipython_config.py' + + description = """ + The IPython QtConsole. + + This launches a Console-style application using Qt. It is not a full + console, in that launched terminal subprocesses will not. + + The QtConsole supports various extra features beyond the + + """ + classes = [IPKernelApp, IPythonWidget, ZMQInteractiveShell, ProfileDir, Session] flags = Dict(flags) aliases = Dict(aliases) diff --git a/IPython/frontend/terminal/ipapp.py b/IPython/frontend/terminal/ipapp.py index e30986d..0a82659 100755 --- a/IPython/frontend/terminal/ipapp.py +++ b/IPython/frontend/terminal/ipapp.py @@ -168,13 +168,6 @@ flags['quick']=( "Enable quick startup with no config files." ) -nosep_config = Config() -nosep_config.InteractiveShell.separate_in = '' -nosep_config.InteractiveShell.separate_out = '' -nosep_config.InteractiveShell.separate_out2 = '' - -flags['nosep']=(nosep_config, "Eliminate all spacing between prompts.") - flags['i'] = ( {'TerminalIPythonApp' : {'force_interact' : True}}, "If running code from the command line, become interactive afterwards." @@ -190,8 +183,6 @@ aliases.update(shell_aliases) # it's possible we don't want short aliases for *all* of these: aliases.update(dict( - editor='TerminalInteractiveShell.editor', - sl='TerminalInteractiveShell.screen_length', gui='TerminalIPythonApp.gui', pylab='TerminalIPythonApp.pylab', )) @@ -363,3 +354,4 @@ def launch_new_instance(): if __name__ == '__main__': launch_new_instance() + diff --git a/IPython/parallel/apps/win32support.py b/IPython/parallel/apps/win32support.py index 48cb168..ea0d3e5 100644 --- a/IPython/parallel/apps/win32support.py +++ b/IPython/parallel/apps/win32support.py @@ -1,7 +1,7 @@ #!/usr/bin/env python """Utility for forwarding file read events over a zmq socket. -This is necessary because select on Windows only supports +This is necessary because select on Windows only supports sockets, not FDs. Authors: @@ -37,7 +37,7 @@ class ForwarderThread(Thread): self.fd = fd def run(self): - """loop through lines in self.fd, and send them over self.sock""" + """Loop through lines in self.fd, and send them over self.sock.""" line = self.fd.readline() # allow for files opened in unicode mode if isinstance(line, unicode): @@ -52,7 +52,7 @@ class ForwarderThread(Thread): self.sock.close() def forward_read_events(fd, context=None): - """forward read events from an FD over a socket. + """Forward read events from an FD over a socket. This method wraps a file in a socket pair, so it can be polled for read events by select (specifically zmq.eventloop.ioloop) @@ -70,4 +70,4 @@ def forward_read_events(fd, context=None): return pull -__all__ = ['forward_read_events'] \ No newline at end of file +__all__ = ['forward_read_events'] diff --git a/IPython/zmq/kernelapp.py b/IPython/zmq/kernelapp.py index a732968..f4672fb 100644 --- a/IPython/zmq/kernelapp.py +++ b/IPython/zmq/kernelapp.py @@ -212,3 +212,4 @@ class KernelApp(BaseIPythonApplication): self.kernel.start() except KeyboardInterrupt: pass +