##// END OF EJS Templates
code updates per review of PR #454
MinRK -
Show More
@@ -350,15 +350,27 b' class KeyValueConfigLoader(CommandLineConfigLoader):'
350 >>> cl.load_config(["foo='bar'","A.name='brian'","B.number=0"])
350 >>> cl.load_config(["foo='bar'","A.name='brian'","B.number=0"])
351 {'A': {'name': 'brian'}, 'B': {'number': 0}, 'foo': 'bar'}
351 {'A': {'name': 'brian'}, 'B': {'number': 0}, 'foo': 'bar'}
352 """
352 """
353 self.clear()
353 if argv is None:
354 if argv is None:
354 argv = sys.argv[1:]
355 argv = sys.argv[1:]
355 self.argv = argv
356 self.argv = argv
356 self.aliases = aliases or {}
357 self.aliases = aliases or {}
357 self.flags = flags or {}
358 self.flags = flags or {}
359
360
361 def clear(self):
362 super(KeyValueConfigLoader, self).clear()
363 self.extra_args = []
364
358
365
359 def load_config(self, argv=None, aliases=None, flags=None):
366 def load_config(self, argv=None, aliases=None, flags=None):
360 """Parse the configuration and generate the Config object.
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 Parameters
374 Parameters
363 ----------
375 ----------
364 argv : list, optional
376 argv : list, optional
@@ -384,8 +396,6 b' class KeyValueConfigLoader(CommandLineConfigLoader):'
384 if flags is None:
396 if flags is None:
385 flags = self.flags
397 flags = self.flags
386
398
387 self.extra_args = []
388
389 for item in argv:
399 for item in argv:
390 if kv_pattern.match(item):
400 if kv_pattern.match(item):
391 lhs,rhs = item.split('=',1)
401 lhs,rhs = item.split('=',1)
@@ -28,6 +28,7 b' import sys'
28
28
29 from IPython.config.application import boolean_flag
29 from IPython.config.application import boolean_flag
30 from IPython.config.configurable import Configurable
30 from IPython.config.configurable import Configurable
31 from IPython.config.loader import Config
31 from IPython.utils.path import filefind
32 from IPython.utils.path import filefind
32 from IPython.utils.traitlets import Unicode, Instance, List
33 from IPython.utils.traitlets import Unicode, Instance, List
33
34
@@ -63,7 +64,7 b" addflag('color-info', 'InteractiveShell.color_info',"
63 it and turn it on permanently in your ipython_config.py file if it
64 it and turn it on permanently in your ipython_config.py file if it
64 works for you. Test it and turn it on permanently if it works with
65 works for you. Test it and turn it on permanently if it works with
65 your system. The magic function %%color_info allows you to toggle this
66 your system. The magic function %%color_info allows you to toggle this
66 inter- actively for testing.""",
67 interactively for testing.""",
67 "Disable using colors for info related things."
68 "Disable using colors for info related things."
68 )
69 )
69 addflag('deep-reload', 'InteractiveShell.deep_reload',
70 addflag('deep-reload', 'InteractiveShell.deep_reload',
@@ -78,6 +79,13 b" addflag('deep-reload', 'InteractiveShell.deep_reload',"
78 dreload()].""",
79 dreload()].""",
79 "Disable deep (recursive) reloading by default."
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 # it's possible we don't want short aliases for *all* of these:
90 # it's possible we don't want short aliases for *all* of these:
83 shell_aliases = dict(
91 shell_aliases = dict(
@@ -86,13 +94,6 b' shell_aliases = dict('
86 colors='InteractiveShell.colors',
94 colors='InteractiveShell.colors',
87 logfile='InteractiveShell.logfile',
95 logfile='InteractiveShell.logfile',
88 log_append='InteractiveShell.logappend',
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 c='InteractiveShellApp.code_to_run',
97 c='InteractiveShellApp.code_to_run',
97 ext='InteractiveShellApp.extra_extension',
98 ext='InteractiveShellApp.extra_extension',
98 )
99 )
@@ -79,13 +79,14 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
79 default_value='inside', config=True,
79 default_value='inside', config=True,
80 help="""
80 help="""
81 The type of paging to use. Valid values are:
81 The type of paging to use. Valid values are:
82
82 'inside' : The widget pages like a traditional terminal.
83 'inside' : The widget pages like a traditional terminal.
83 'hsplit' : When paging is requested, the widget is split
84 'hsplit' : When paging is requested, the widget is split
84 : horizontally. The top pane contains the console, and the
85 horizontally. The top pane contains the console, and the
85 : bottom pane contains the paged text.
86 bottom pane contains the paged text.
86 'vsplit' : Similar to 'hsplit', except that a vertical splitter used.
87 'vsplit' : Similar to 'hsplit', except that a vertical splitter used.
87 'custom' : No action is taken by the widget beyond emitting a
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 'none' : The text is written directly to the console.
90 'none' : The text is written directly to the console.
90 """)
91 """)
91
92
@@ -1,4 +1,15 b''
1 """ A minimal application using the Qt console-style IPython frontend.
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 colors = 'ZMQInteractiveShell.colors',
212 colors = 'ZMQInteractiveShell.colors',
202
213
203 editor = 'IPythonWidget.editor',
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 # IPythonQtConsole
218 # IPythonQtConsole
213 #-----------------------------------------------------------------------------
219 #-----------------------------------------------------------------------------
214
215 class IPythonQtConsoleApp(BaseIPythonApplication):
220 class IPythonQtConsoleApp(BaseIPythonApplication):
216 name = 'ipython-qtconsole'
221 name = 'ipython-qtconsole'
217 default_config_file_name='ipython_config.py'
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 classes = [IPKernelApp, IPythonWidget, ZMQInteractiveShell, ProfileDir, Session]
234 classes = [IPKernelApp, IPythonWidget, ZMQInteractiveShell, ProfileDir, Session]
219 flags = Dict(flags)
235 flags = Dict(flags)
220 aliases = Dict(aliases)
236 aliases = Dict(aliases)
@@ -168,13 +168,6 b" flags['quick']=("
168 "Enable quick startup with no config files."
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 flags['i'] = (
171 flags['i'] = (
179 {'TerminalIPythonApp' : {'force_interact' : True}},
172 {'TerminalIPythonApp' : {'force_interact' : True}},
180 "If running code from the command line, become interactive afterwards."
173 "If running code from the command line, become interactive afterwards."
@@ -190,8 +183,6 b' aliases.update(shell_aliases)'
190
183
191 # it's possible we don't want short aliases for *all* of these:
184 # it's possible we don't want short aliases for *all* of these:
192 aliases.update(dict(
185 aliases.update(dict(
193 editor='TerminalInteractiveShell.editor',
194 sl='TerminalInteractiveShell.screen_length',
195 gui='TerminalIPythonApp.gui',
186 gui='TerminalIPythonApp.gui',
196 pylab='TerminalIPythonApp.pylab',
187 pylab='TerminalIPythonApp.pylab',
197 ))
188 ))
@@ -363,3 +354,4 b' def launch_new_instance():'
363
354
364 if __name__ == '__main__':
355 if __name__ == '__main__':
365 launch_new_instance()
356 launch_new_instance()
357
@@ -1,7 +1,7 b''
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 """Utility for forwarding file read events over a zmq socket.
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 Authors:
6 Authors:
7
7
@@ -37,7 +37,7 b' class ForwarderThread(Thread):'
37 self.fd = fd
37 self.fd = fd
38
38
39 def run(self):
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 line = self.fd.readline()
41 line = self.fd.readline()
42 # allow for files opened in unicode mode
42 # allow for files opened in unicode mode
43 if isinstance(line, unicode):
43 if isinstance(line, unicode):
@@ -52,7 +52,7 b' class ForwarderThread(Thread):'
52 self.sock.close()
52 self.sock.close()
53
53
54 def forward_read_events(fd, context=None):
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 This method wraps a file in a socket pair, so it can
57 This method wraps a file in a socket pair, so it can
58 be polled for read events by select (specifically zmq.eventloop.ioloop)
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 return pull
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 self.kernel.start()
212 self.kernel.start()
213 except KeyboardInterrupt:
213 except KeyboardInterrupt:
214 pass
214 pass
215
General Comments 0
You need to be logged in to leave comments. Login now