Activate the interactive interpreter. __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start the interpreter shell with the given local and global namespaces, and optionally print a header string at startup. The shell can be globally activated/deacti
(self, header='', local_ns=None, module=None, dummy=None,
stack_depth=1, global_ns=None, compile_flags=None, **kw)
| 175 | self.register_magics(EmbeddedMagics) |
| 176 | |
| 177 | def __call__(self, header='', local_ns=None, module=None, dummy=None, |
| 178 | stack_depth=1, global_ns=None, compile_flags=None, **kw): |
| 179 | """Activate the interactive interpreter. |
| 180 | |
| 181 | __call__(self,header='',local_ns=None,module=None,dummy=None) -> Start |
| 182 | the interpreter shell with the given local and global namespaces, and |
| 183 | optionally print a header string at startup. |
| 184 | |
| 185 | The shell can be globally activated/deactivated using the |
| 186 | dummy_mode attribute. This allows you to turn off a shell used |
| 187 | for debugging globally. |
| 188 | |
| 189 | However, *each* time you call the shell you can override the current |
| 190 | state of dummy_mode with the optional keyword parameter 'dummy'. For |
| 191 | example, if you set dummy mode on with IPShell.dummy_mode = True, you |
| 192 | can still have a specific call work by making it as IPShell(dummy=False). |
| 193 | """ |
| 194 | |
| 195 | # we are called, set the underlying interactiveshell not to exit. |
| 196 | self.keep_running = True |
| 197 | |
| 198 | # If the user has turned it off, go away |
| 199 | clid = kw.pop('_call_location_id', None) |
| 200 | if not clid: |
| 201 | frame = sys._getframe(1) |
| 202 | clid = '%s:%s' % (frame.f_code.co_filename, frame.f_lineno) |
| 203 | self._call_location_id = clid |
| 204 | |
| 205 | if not self.embedded_active: |
| 206 | return |
| 207 | |
| 208 | # Normal exits from interactive mode set this flag, so the shell can't |
| 209 | # re-enter (it checks this variable at the start of interactive mode). |
| 210 | self.exit_now = False |
| 211 | |
| 212 | # Allow the dummy parameter to override the global __dummy_mode |
| 213 | if dummy or (dummy != 0 and self.dummy_mode): |
| 214 | return |
| 215 | |
| 216 | # self.banner is auto computed |
| 217 | if header: |
| 218 | self.old_banner2 = self.banner2 |
| 219 | self.banner2 = self.banner2 + '\n' + header + '\n' |
| 220 | else: |
| 221 | self.old_banner2 = '' |
| 222 | |
| 223 | if self.display_banner: |
| 224 | self.show_banner() |
| 225 | |
| 226 | # Call the embedding code with a stack depth of 1 so it can skip over |
| 227 | # our call and get the original caller's namespaces. |
| 228 | self.mainloop(local_ns, module, stack_depth=stack_depth, |
| 229 | global_ns=global_ns, compile_flags=compile_flags) |
| 230 | |
| 231 | self.banner2 = self.old_banner2 |
| 232 | |
| 233 | if self.exit_msg is not None: |
| 234 | print(self.exit_msg) |
nothing calls this directly
no test coverage detected