Show More
@@ -108,6 +108,14 b' class EmbeddedMagics(Magics):' | |||||
108 | self.shell.ask_exit() |
|
108 | self.shell.ask_exit() | |
109 |
|
109 | |||
110 |
|
110 | |||
|
111 | class _Sentinel: | |||
|
112 | def __init__(self, repr): | |||
|
113 | assert isinstance(repr, str) | |||
|
114 | self.repr = repr | |||
|
115 | ||||
|
116 | def __repr__(self): | |||
|
117 | return repr | |||
|
118 | ||||
111 |
|
119 | |||
112 | class InteractiveShellEmbed(TerminalInteractiveShell): |
|
120 | class InteractiveShellEmbed(TerminalInteractiveShell): | |
113 |
|
121 | |||
@@ -148,9 +156,9 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||||
148 | self._call_location_id) |
|
156 | self._call_location_id) | |
149 |
|
157 | |||
150 | def __init__(self, **kw): |
|
158 | def __init__(self, **kw): | |
151 | if kw.get('user_global_ns', None) is not None: |
|
159 | assert ( | |
152 | raise DeprecationWarning( |
|
160 | "user_global_ns" not in kw | |
153 |
|
|
161 | ), "Key word argument `user_global_ns` has been replaced by `user_module` since IPython 4.0." | |
154 |
|
162 | |||
155 | clid = kw.pop('_init_location_id', None) |
|
163 | clid = kw.pop('_init_location_id', None) | |
156 | if not clid: |
|
164 | if not clid: | |
@@ -176,8 +184,16 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||||
176 | super(InteractiveShellEmbed, self).init_magics() |
|
184 | super(InteractiveShellEmbed, self).init_magics() | |
177 | self.register_magics(EmbeddedMagics) |
|
185 | self.register_magics(EmbeddedMagics) | |
178 |
|
186 | |||
179 | def __call__(self, header='', local_ns=None, module=None, dummy=None, |
|
187 | def __call__( | |
180 | stack_depth=1, global_ns=None, compile_flags=None, **kw): |
|
188 | self, | |
|
189 | header="", | |||
|
190 | local_ns=None, | |||
|
191 | module=None, | |||
|
192 | dummy=None, | |||
|
193 | stack_depth=1, | |||
|
194 | compile_flags=None, | |||
|
195 | **kw | |||
|
196 | ): | |||
181 | """Activate the interactive interpreter. |
|
197 | """Activate the interactive interpreter. | |
182 |
|
198 | |||
183 | __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start |
|
199 | __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start | |
@@ -227,8 +243,9 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||||
227 |
|
243 | |||
228 | # Call the embedding code with a stack depth of 1 so it can skip over |
|
244 | # Call the embedding code with a stack depth of 1 so it can skip over | |
229 | # our call and get the original caller's namespaces. |
|
245 | # our call and get the original caller's namespaces. | |
230 | self.mainloop(local_ns, module, stack_depth=stack_depth, |
|
246 | self.mainloop( | |
231 |
|
|
247 | local_ns, module, stack_depth=stack_depth, compile_flags=compile_flags | |
|
248 | ) | |||
232 |
|
249 | |||
233 | self.banner2 = self.old_banner2 |
|
250 | self.banner2 = self.old_banner2 | |
234 |
|
251 | |||
@@ -238,14 +255,19 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||||
238 | if self.should_raise: |
|
255 | if self.should_raise: | |
239 | raise KillEmbedded('Embedded IPython raising error, as user requested.') |
|
256 | raise KillEmbedded('Embedded IPython raising error, as user requested.') | |
240 |
|
257 | |||
241 |
|
258 | def mainloop( | ||
242 | def mainloop(self, local_ns=None, module=None, stack_depth=0, |
|
259 | self, | |
243 | display_banner=None, global_ns=None, compile_flags=None): |
|
260 | local_ns=None, | |
|
261 | module=None, | |||
|
262 | stack_depth=0, | |||
|
263 | compile_flags=None, | |||
|
264 | ): | |||
244 | """Embeds IPython into a running python program. |
|
265 | """Embeds IPython into a running python program. | |
245 |
|
266 | |||
246 | Parameters |
|
267 | Parameters | |
247 | ---------- |
|
268 | ---------- | |
248 |
|
269 | |||
|
270 | ||||
249 | local_ns, module |
|
271 | local_ns, module | |
250 | Working local namespace (a dict) and module (a module or similar |
|
272 | Working local namespace (a dict) and module (a module or similar | |
251 | object). If given as None, they are automatically taken from the scope |
|
273 | object). If given as None, they are automatically taken from the scope | |
@@ -266,12 +288,6 b' class InteractiveShellEmbed(TerminalInteractiveShell):' | |||||
266 |
|
288 | |||
267 | """ |
|
289 | """ | |
268 |
|
290 | |||
269 | if (global_ns is not None) and (module is None): |
|
|||
270 | raise DeprecationWarning("'global_ns' keyword argument is deprecated, and has been removed in IPython 5.0 use `module` keyword argument instead.") |
|
|||
271 |
|
||||
272 | if (display_banner is not None): |
|
|||
273 | warnings.warn("The display_banner parameter is deprecated since IPython 4.0", DeprecationWarning) |
|
|||
274 |
|
||||
275 | # Get locals and globals from caller |
|
291 | # Get locals and globals from caller | |
276 | if ((local_ns is None or module is None or compile_flags is None) |
|
292 | if ((local_ns is None or module is None or compile_flags is None) | |
277 | and self.default_user_namespaces): |
|
293 | and self.default_user_namespaces): |
General Comments 0
You need to be logged in to leave comments.
Login now