##// END OF EJS Templates
code updates per review of PR #454
MinRK -
Show More
@@ -350,15 +350,27 b' class KeyValueConfigLoader(CommandLineConfigLoader):'
350 350 >>> cl.load_config(["foo='bar'","A.name='brian'","B.number=0"])
351 351 {'A': {'name': 'brian'}, 'B': {'number': 0}, 'foo': 'bar'}
352 352 """
353 self.clear()
353 354 if argv is None:
354 355 argv = sys.argv[1:]
355 356 self.argv = argv
356 357 self.aliases = aliases or {}
357 358 self.flags = flags or {}
359
360
361 def clear(self):
362 super(KeyValueConfigLoader, self).clear()
363 self.extra_args = []
364
358 365
359 366 def load_config(self, argv=None, aliases=None, flags=None):
360 367 """Parse the configuration and generate the Config object.
361
368
369 After loading, any arguments that are not key-value or
370 flags will be stored in self.extra_args - a list of
371 unparsed command-line arguments. This is used for
372 arguments such as input files or subcommands.
373
362 374 Parameters
363 375 ----------
364 376 argv : list, optional
@@ -384,8 +396,6 b' class KeyValueConfigLoader(CommandLineConfigLoader):'
384 396 if flags is None:
385 397 flags = self.flags
386 398
387 self.extra_args = []
388
389 399 for item in argv:
390 400 if kv_pattern.match(item):
391 401 lhs,rhs = item.split('=',1)
@@ -28,6 +28,7 b' import sys'
28 28
29 29 from IPython.config.application import boolean_flag
30 30 from IPython.config.configurable import Configurable
31 from IPython.config.loader import Config
31 32 from IPython.utils.path import filefind
32 33 from IPython.utils.traitlets import Unicode, Instance, List
33 34
@@ -63,7 +64,7 b" addflag('color-info', 'InteractiveShell.color_info',"
63 64 it and turn it on permanently in your ipython_config.py file if it
64 65 works for you. Test it and turn it on permanently if it works with
65 66 your system. The magic function %%color_info allows you to toggle this
66 inter- actively for testing.""",
67 interactively for testing.""",
67 68 "Disable using colors for info related things."
68 69 )
69 70 addflag('deep-reload', 'InteractiveShell.deep_reload',
@@ -78,6 +79,13 b" addflag('deep-reload', 'InteractiveShell.deep_reload',"
78 79 dreload()].""",
79 80 "Disable deep (recursive) reloading by default."
80 81 )
82 nosep_config = Config()
83 nosep_config.InteractiveShell.separate_in = ''
84 nosep_config.InteractiveShell.separate_out = ''
85 nosep_config.InteractiveShell.separate_out2 = ''
86
87 shell_flags['nosep']=(nosep_config, "Eliminate all spacing between prompts.")
88
81 89
82 90 # it's possible we don't want short aliases for *all* of these:
83 91 shell_aliases = dict(
@@ -86,13 +94,6 b' shell_aliases = dict('
86 94 colors='InteractiveShell.colors',
87 95 logfile='InteractiveShell.logfile',
88 96 log_append='InteractiveShell.logappend',
89 pi1='InteractiveShell.prompt_in1',
90 pi2='InteractiveShell.prompt_in1',
91 po='InteractiveShell.prompt_out',
92 si='InteractiveShell.separate_in',
93 so='InteractiveShell.separate_out',
94 so2='InteractiveShell.separate_out2',
95 xmode='InteractiveShell.xmode',
96 97 c='InteractiveShellApp.code_to_run',
97 98 ext='InteractiveShellApp.extra_extension',
98 99 )
@@ -79,13 +79,14 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
79 79 default_value='inside', config=True,
80 80 help="""
81 81 The type of paging to use. Valid values are:
82
82 83 'inside' : The widget pages like a traditional terminal.
83 84 'hsplit' : When paging is requested, the widget is split
84 : horizontally. The top pane contains the console, and the
85 : bottom pane contains the paged text.
85 horizontally. The top pane contains the console, and the
86 bottom pane contains the paged text.
86 87 'vsplit' : Similar to 'hsplit', except that a vertical splitter used.
87 88 'custom' : No action is taken by the widget beyond emitting a
88 : 'custom_page_requested(str)' signal.
89 'custom_page_requested(str)' signal.
89 90 'none' : The text is written directly to the console.
90 91 """)
91 92
@@ -1,4 +1,15 b''
1 1 """ A minimal application using the Qt console-style IPython frontend.
2
3 This is not a complete console app, as subprocess will not be able to receive
4 input, there is no real readline support, among other limitations.
5
6 Authors:
7
8 * Evan Patterson
9 * Min RK
10 * Erik Tollerud
11 * Fernando Perez
12
2 13 """
3 14
4 15 #-----------------------------------------------------------------------------
@@ -201,20 +212,25 b' aliases.update(dict('
201 212 colors = 'ZMQInteractiveShell.colors',
202 213
203 214 editor = 'IPythonWidget.editor',
204 pi = 'IPythonWidget.in_prompt',
205 po = 'IPythonWidget.out_prompt',
206 si = 'IPythonWidget.input_sep',
207 so = 'IPythonWidget.output_sep',
208 so2 = 'IPythonWidget.output_sep2',
209 215 ))
210 216
211 217 #-----------------------------------------------------------------------------
212 218 # IPythonQtConsole
213 219 #-----------------------------------------------------------------------------
214
215 220 class IPythonQtConsoleApp(BaseIPythonApplication):
216 221 name = 'ipython-qtconsole'
217 222 default_config_file_name='ipython_config.py'
223
224 description = """
225 The IPython QtConsole.
226
227 This launches a Console-style application using Qt. It is not a full
228 console, in that launched terminal subprocesses will not.
229
230 The QtConsole supports various extra features beyond the
231
232 """
233
218 234 classes = [IPKernelApp, IPythonWidget, ZMQInteractiveShell, ProfileDir, Session]
219 235 flags = Dict(flags)
220 236 aliases = Dict(aliases)
@@ -168,13 +168,6 b" flags['quick']=("
168 168 "Enable quick startup with no config files."
169 169 )
170 170
171 nosep_config = Config()
172 nosep_config.InteractiveShell.separate_in = ''
173 nosep_config.InteractiveShell.separate_out = ''
174 nosep_config.InteractiveShell.separate_out2 = ''
175
176 flags['nosep']=(nosep_config, "Eliminate all spacing between prompts.")
177
178 171 flags['i'] = (
179 172 {'TerminalIPythonApp' : {'force_interact' : True}},
180 173 "If running code from the command line, become interactive afterwards."
@@ -190,8 +183,6 b' aliases.update(shell_aliases)'
190 183
191 184 # it's possible we don't want short aliases for *all* of these:
192 185 aliases.update(dict(
193 editor='TerminalInteractiveShell.editor',
194 sl='TerminalInteractiveShell.screen_length',
195 186 gui='TerminalIPythonApp.gui',
196 187 pylab='TerminalIPythonApp.pylab',
197 188 ))
@@ -363,3 +354,4 b' def launch_new_instance():'
363 354
364 355 if __name__ == '__main__':
365 356 launch_new_instance()
357
@@ -1,7 +1,7 b''
1 1 #!/usr/bin/env python
2 2 """Utility for forwarding file read events over a zmq socket.
3 3
4 This is necessary because select on Windows only supports
4 This is necessary because select on Windows only supports sockets, not FDs.
5 5
6 6 Authors:
7 7
@@ -37,7 +37,7 b' class ForwarderThread(Thread):'
37 37 self.fd = fd
38 38
39 39 def run(self):
40 """loop through lines in self.fd, and send them over self.sock"""
40 """Loop through lines in self.fd, and send them over self.sock."""
41 41 line = self.fd.readline()
42 42 # allow for files opened in unicode mode
43 43 if isinstance(line, unicode):
@@ -52,7 +52,7 b' class ForwarderThread(Thread):'
52 52 self.sock.close()
53 53
54 54 def forward_read_events(fd, context=None):
55 """forward read events from an FD over a socket.
55 """Forward read events from an FD over a socket.
56 56
57 57 This method wraps a file in a socket pair, so it can
58 58 be polled for read events by select (specifically zmq.eventloop.ioloop)
@@ -70,4 +70,4 b' def forward_read_events(fd, context=None):'
70 70 return pull
71 71
72 72
73 __all__ = ['forward_read_events'] No newline at end of file
73 __all__ = ['forward_read_events']
@@ -212,3 +212,4 b' class KernelApp(BaseIPythonApplication):'
212 212 self.kernel.start()
213 213 except KeyboardInterrupt:
214 214 pass
215
General Comments 0
You need to be logged in to leave comments. Login now