Skip to content

Commit

Permalink
code updates per review of PR #454
Browse files Browse the repository at this point in the history
  • Loading branch information
minrk committed Jun 20, 2011
1 parent 7733e3c commit 087a201
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 33 deletions.
16 changes: 13 additions & 3 deletions IPython/config/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,15 +350,27 @@ def __init__(self, argv=None, aliases=None, flags=None):
>>> 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
Expand All @@ -384,8 +396,6 @@ def load_config(self, argv=None, aliases=None, flags=None):
if flags is None:
flags = self.flags

self.extra_args = []

for item in argv:
if kv_pattern.match(item):
lhs,rhs = item.split('=',1)
Expand Down
17 changes: 9 additions & 8 deletions IPython/core/shellapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

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

Expand Down Expand Up @@ -63,7 +64,7 @@
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',
Expand All @@ -78,6 +79,13 @@
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(
Expand All @@ -86,13 +94,6 @@
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',
)
Expand Down
7 changes: 4 additions & 3 deletions IPython/frontend/qt/console/console_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
""")

Expand Down
28 changes: 22 additions & 6 deletions IPython/frontend/qt/console/ipythonqt.py
Original file line number Diff line number Diff line change
@@ -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
"""

#-----------------------------------------------------------------------------
Expand Down Expand Up @@ -201,20 +212,25 @@ def closeEvent(self, event):
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)
Expand Down
10 changes: 1 addition & 9 deletions IPython/frontend/terminal/ipapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,6 @@ def make_report(self,traceback):
"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."
Expand All @@ -190,8 +183,6 @@ def make_report(self,traceback):

# 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',
))
Expand Down Expand Up @@ -363,3 +354,4 @@ def launch_new_instance():

if __name__ == '__main__':
launch_new_instance()

8 changes: 4 additions & 4 deletions IPython/parallel/apps/win32support.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, sock, fd):
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):
Expand All @@ -52,7 +52,7 @@ def run(self):
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)
Expand All @@ -70,4 +70,4 @@ def forward_read_events(fd, context=None):
return pull


__all__ = ['forward_read_events']
__all__ = ['forward_read_events']
1 change: 1 addition & 0 deletions IPython/zmq/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,3 +212,4 @@ def start(self):
self.kernel.start()
except KeyboardInterrupt:
pass

0 comments on commit 087a201

Please sign in to comment.