def __init__(self, argv=None, banner='', exit_msg=None, rc_override=None, user_ns=None): self.set_banner(banner) self.set_exit_msg(exit_msg) self.set_dummy_mode(0) self.sys_displayhook_ori = sys.displayhook try: self.sys_ipcompleter_ori = sys.ipcompleter except: pass # not nested with IPython self.IP = make_IPython(argv, rc_override=rc_override, embedded=True, user_ns=user_ns, shell_class=V8InteractiveShell) ip = ipapi.IPApi(self.IP) ip.expose_magic("kill_embedded", kill_embedded) self.sys_displayhook_embed = sys.displayhook sys.displayhook = self.sys_displayhook_ori sys.excepthook = ultraTB.FormattedTB(color_scheme=self.IP.rc.colors, mode=self.IP.rc.xmode, call_pdb=self.IP.rc.pdb) self.restore_system_completer()
def init_ipython_session(argv=[], auto_symbols=False, auto_int_to_Integer=False): """Construct new IPython session. """ import IPython if V(IPython.__version__) >= '0.11': # use an app to parse the command line, and init config # IPython 1.0 deprecates the frontend module, so we import directly # from the terminal module to prevent a deprecation message from being # shown. if V(IPython.__version__) >= '1.0': from IPython.terminal import ipapp else: from IPython.frontend.terminal import ipapp app = ipapp.TerminalIPythonApp() # don't draw IPython banner during initialization: app.display_banner = False app.initialize(argv) if auto_symbols: readline = import_module("readline") if readline: enable_automatic_symbols(app) if auto_int_to_Integer: enable_automatic_int_sympification(app) return app.shell else: from IPython.Shell import make_IPython return make_IPython(argv)
def init_ipython_session(argv=[], auto_symbols=False, auto_int_to_Integer=False): """Construct new IPython session. """ import IPython if IPython.__version__ >= '0.11': # use an app to parse the command line, and init config # IPython 1.0 deprecates the frontend module, so we import directly # from the terminal module to prevent a deprecation message from being # shown. if IPython.__version__ >= '1.0': from IPython.terminal import ipapp else: from IPython.frontend.terminal import ipapp app = ipapp.TerminalIPythonApp() # don't draw IPython banner during initialization: app.display_banner = False app.initialize(argv) if auto_symbols: readline = import_module("readline") if readline: enable_automatic_symbols(app) if auto_int_to_Integer: enable_automatic_int_sympification(app) return app.shell else: from IPython.Shell import make_IPython return make_IPython(argv)
def _init_ipython_session(argv=[]): """Construct new IPython session. """ import IPython if IPython.__version__ >= '0.11': from IPython.frontend.terminal import ipapp # use an app to parse the command line, and init config app = ipapp.TerminalIPythonApp() # don't draw IPython banner during initialization: app.display_banner = False app.initialize(argv) return app.shell else: from IPython.Shell import make_IPython return make_IPython(argv)
def _init_ipython_session(argv=[], auto=False): """Construct new IPython session. """ import IPython if IPython.__version__ >= '0.11': # use an app to parse the command line, and init config from IPython.frontend.terminal import ipapp app = ipapp.TerminalIPythonApp() # don't draw IPython banner during initialization: app.display_banner = False app.initialize(argv) import re re_nameerror = re.compile("name '(?P<symbol>[A-Za-z_][A-Za-z0-9_]*)' is not defined") def _handler(self, etype, value, tb, tb_offset=None): """Handle :exc:`NameError` exception and allow injection of missing symbols. """ if etype is NameError and tb.tb_next and not tb.tb_next.tb_next: match = re_nameerror.match(str(value)) if match is not None: self.run_cell("%(symbol)s = Symbol('%(symbol)s')" % {'symbol': match.group("symbol")}, store_history=False) try: code = self.user_ns_hidden['In'][-1] except (KeyError, IndexError): pass else: self.run_cell(code, store_history=False) return None stb = self.InteractiveTB.structured_traceback(etype, value, tb, tb_offset=tb_offset) self._showtraceback(etype, value, stb) if auto: app.shell.set_custom_exc((NameError,), _handler) return app.shell else: from IPython.Shell import make_IPython return make_IPython(argv)
def init_ipython_session(argv=[], auto_symbols=False, auto_int_to_Integer=False): """Construct new IPython session. """ import IPython if IPython.__version__ >= '0.11': # use an app to parse the command line, and init config from IPython.frontend.terminal import ipapp app = ipapp.TerminalIPythonApp() # don't draw IPython banner during initialization: app.display_banner = False app.initialize(argv) if auto_symbols: enable_automatic_symbols(app) if auto_int_to_Integer: enable_automatic_int_sympification(app) return app.shell else: from IPython.Shell import make_IPython return make_IPython(argv)
def __init__(self,argv=None,banner='',exit_msg=None,rc_override=None, user_ns=None): self.set_banner(banner) self.set_exit_msg(exit_msg) self.set_dummy_mode(0) self.sys_displayhook_ori = sys.displayhook try: self.sys_ipcompleter_ori = sys.ipcompleter except: pass # not nested with IPython self.IP = make_IPython(argv,rc_override=rc_override, embedded=True, user_ns=user_ns, shell_class=V8InteractiveShell) ip = ipapi.IPApi(self.IP) ip.expose_magic("kill_embedded",kill_embedded) self.sys_displayhook_embed = sys.displayhook sys.displayhook = self.sys_displayhook_ori sys.excepthook = ultraTB.FormattedTB(color_scheme = self.IP.rc.colors, mode = self.IP.rc.xmode, call_pdb = self.IP.rc.pdb) self.restore_system_completer()
def _init_ipython_session(argv=[]): """Construct new IPython session. """ from IPython.Shell import make_IPython return make_IPython(argv)