##// END OF EJS Templates
Merge pull request #6536 from minrk/parent-config...
Thomas Kluyver -
r18031:6baa9d94 merge
parent child Browse files
Show More
@@ -123,7 +123,16 b' class Application(SingletonConfigurable):'
123 123
124 124 # A sequence of Configurable subclasses whose config=True attributes will
125 125 # be exposed at the command line.
126 classes = List([])
126 classes = []
127 @property
128 def _help_classes(self):
129 """Define `App.help_classes` if CLI classes should differ from config file classes"""
130 return getattr(self, 'help_classes', self.classes)
131
132 @property
133 def _config_classes(self):
134 """Define `App.config_classes` if config file classes should differ from CLI classes."""
135 return getattr(self, 'config_classes', self.classes)
127 136
128 137 # The version string of this application.
129 138 version = Unicode(u'0.0')
@@ -256,7 +265,7 b' class Application(SingletonConfigurable):'
256 265
257 266 lines = []
258 267 classdict = {}
259 for cls in self.classes:
268 for cls in self._help_classes:
260 269 # include all parents (up to, but excluding Configurable) in available names
261 270 for c in cls.mro()[:-3]:
262 271 classdict[c.__name__] = c
@@ -331,7 +340,8 b' class Application(SingletonConfigurable):'
331 340 self.print_options()
332 341
333 342 if classes:
334 if self.classes:
343 help_classes = self._help_classes
344 if help_classes:
335 345 print("Class parameters")
336 346 print("----------------")
337 347 print()
@@ -339,7 +349,7 b' class Application(SingletonConfigurable):'
339 349 print(p)
340 350 print()
341 351
342 for cls in self.classes:
352 for cls in help_classes:
343 353 cls.class_print_help()
344 354 print()
345 355 else:
@@ -412,7 +422,7 b' class Application(SingletonConfigurable):'
412 422 # it will be a dict by parent classname of classes in our list
413 423 # that are descendents
414 424 mro_tree = defaultdict(list)
415 for cls in self.classes:
425 for cls in self._help_classes:
416 426 clsname = cls.__name__
417 427 for parent in cls.mro()[1:-3]:
418 428 # exclude cls itself and Configurable,HasTraits,object
@@ -530,7 +540,7 b' class Application(SingletonConfigurable):'
530 540 lines.append('')
531 541 lines.append('c = get_config()')
532 542 lines.append('')
533 for cls in self.classes:
543 for cls in self._config_classes:
534 544 lines.append(cls.class_config_section())
535 545 return '\n'.join(lines)
536 546
@@ -7,11 +7,6 b' refactoring of what used to be the IPython/qt/console/qtconsoleapp.py'
7 7 # Copyright (c) IPython Development Team.
8 8 # Distributed under the terms of the Modified BSD License.
9 9
10 #-----------------------------------------------------------------------------
11 # Imports
12 #-----------------------------------------------------------------------------
13
14 # stdlib imports
15 10 import atexit
16 11 import os
17 12 import signal
@@ -19,7 +14,6 b' import sys'
19 14 import uuid
20 15
21 16
22 # Local imports
23 17 from IPython.config.application import boolean_flag
24 18 from IPython.core.profiledir import ProfileDir
25 19 from IPython.kernel.blocking import BlockingKernelClient
@@ -40,18 +34,9 b' from IPython.kernel.zmq.session import Session, default_secure'
40 34 from IPython.kernel.zmq.zmqshell import ZMQInteractiveShell
41 35 from IPython.kernel.connect import ConnectionFileMixin
42 36
43 #-----------------------------------------------------------------------------
44 # Network Constants
45 #-----------------------------------------------------------------------------
46
47 37 from IPython.utils.localinterfaces import localhost
48 38
49 39 #-----------------------------------------------------------------------------
50 # Globals
51 #-----------------------------------------------------------------------------
52
53
54 #-----------------------------------------------------------------------------
55 40 # Aliases and Flags
56 41 #-----------------------------------------------------------------------------
57 42
@@ -98,11 +83,7 b' aliases.update(app_aliases)'
98 83 # Classes
99 84 #-----------------------------------------------------------------------------
100 85
101 #-----------------------------------------------------------------------------
102 # IPythonConsole
103 #-----------------------------------------------------------------------------
104
105 classes = [IPKernelApp, ZMQInteractiveShell, KernelManager, ProfileDir, Session, InlineBackend]
86 classes = [KernelManager, ProfileDir, Session]
106 87
107 88 class IPythonConsoleApp(ConnectionFileMixin):
108 89 name = 'ipython-console-mixin'
@@ -158,8 +139,15 b' class IPythonConsoleApp(ConnectionFileMixin):'
158 139 Set to display confirmation dialog on exit. You can always use 'exit' or 'quit',
159 140 to force a direct exit without any confirmation.""",
160 141 )
161
162
142
143 @property
144 def help_classes(self):
145 """ConsoleApps can configure kernels on the command-line
146
147 But this shouldn't be written to a file
148 """
149 return self.classes + [IPKernelApp] + IPKernelApp.classes
150
163 151 def build_kernel_argv(self, argv=None):
164 152 """build argv to be passed to kernel subprocess"""
165 153 if argv is None:
@@ -261,6 +261,7 b' class ProfileCreate(BaseIPythonApplication):'
261 261 from IPython.terminal.ipapp import TerminalIPythonApp
262 262 apps = [TerminalIPythonApp]
263 263 for app_path in (
264 'IPython.kernel.zmq.kernelapp.IPKernelApp',
264 265 'IPython.qt.console.qtconsoleapp.IPythonQtConsoleApp',
265 266 'IPython.html.notebookapp.NotebookApp',
266 267 'IPython.nbconvert.nbconvertapp.NbConvertApp',
@@ -97,7 +97,7 b' To read more about this, see https://github.com/ipython/ipython/issues/2049'
97 97
98 98 class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,
99 99 ConnectionFileMixin):
100 name='ipkernel'
100 name='ipython-kernel'
101 101 aliases = Dict(kernel_aliases)
102 102 flags = Dict(kernel_flags)
103 103 classes = [IPythonKernel, ZMQInteractiveShell, ProfileDir, Session]
@@ -114,10 +114,6 b' class IPKernelApp(BaseIPythonApplication, InteractiveShellApp,'
114 114 heartbeat = Instance(Heartbeat)
115 115 ports = Dict()
116 116
117 # ipkernel doesn't get its own config file
118 def _config_file_name_default(self):
119 return 'ipython_config.py'
120
121 117 # connection info:
122 118
123 119 @property
@@ -70,11 +70,12 b" if __name__ == '__main__':"
70 70
71 71 write_doc('terminal', 'Terminal IPython options', TerminalIPythonApp().classes)
72 72 write_doc('kernel', 'IPython kernel options', kernel_classes,
73 preamble="These options can be used in :file:`ipython_notebook_config.py` "
74 "or in :file:`ipython_qtconsole_config.py`")
73 preamble="These options can be used in :file:`ipython_kernel_config.py`",
74 )
75 75 nbclasses = set(NotebookApp().classes) - set(kernel_classes)
76 76 write_doc('notebook', 'IPython notebook options', nbclasses,
77 preamble="Any of the :doc:`kernel` can also be used.")
77 preamble="To configure the IPython kernel, see :doc:`kernel`."
78 )
78 79
79 80 try:
80 81 from IPython.qt.console.qtconsoleapp import IPythonQtConsoleApp
@@ -84,5 +85,6 b" if __name__ == '__main__':"
84 85 else:
85 86 qtclasses = set(IPythonQtConsoleApp().classes) - set(kernel_classes)
86 87 write_doc('qtconsole', 'IPython Qt console options', qtclasses,
87 preamble="Any of the :doc:`kernel` can also be used.")
88 preamble="To configure the IPython kernel, see :doc:`kernel`."
89 )
88 90
@@ -95,9 +95,6 b' commented; the minimum set you need to uncomment and edit is the following::'
95 95
96 96 c = get_config()
97 97
98 # Kernel config
99 c.IPKernelApp.pylab = 'inline' # if you want plotting support always
100
101 98 # Notebook config
102 99 c.NotebookApp.certfile = u'/absolute/path/to/your/certificate/mycert.pem'
103 100 c.NotebookApp.ip = '*'
General Comments 0
You need to be logged in to leave comments. Login now