Changeset 3130 for trunk/bin


Ignore:
Timestamp:
05/16/17 23:13:37 (8 years ago)
Author:
Malte Marquarding
Message:

Make Ipython >= 5 compatible

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/asap

    r2929 r3130  
    22import os
    33
    4 def _main010():
    5     from IPython.Shell import IPShellEmbed
     4def _main500():
     5    from IPython.terminal.prompts import Prompts, Token
     6    from traitlets.config.loader import Config
    67
    7     banner = welcome()
    8     exit_msg = ''
    9     args = ['-colors','Linux','-noconfirm_exit', '-readline',
    10             '-xmode', 'Plain', '-autocall', '2', '-autoindent',
    11             '-pi1', 'ASAP> ', '-po', 'asap>: ', '-pprint']
    12     ipshell = IPShellEmbed(args,banner,exit_msg)
     8    class MyPrompt(Prompts):
     9        def in_prompt_tokens(self, cli=None):
     10            return [(Token.Prompt, 'ASAP> ')]
     11
     12        def out_prompt_tokens(self, cli=None):
     13            return [(Token.OutPrompt, 'asap>: ')]
     14
     15    cfg = Config()
     16    cfg.TerminalInteractiveShell.colors = "Linux"
     17    cfg.TerminalInteractiveShell.prompts_class=MyPrompt
     18    from IPython.terminal.embed import InteractiveShellEmbed
     19    ipshell = InteractiveShellEmbed(config=cfg,
     20                                    banner1 = welcome(),
     21                                    exit_msg = '')
    1322    return ipshell
    14 
    15 
     23   
    1624def _main011():
    1725    from IPython.config.loader import Config
     
    4149    vitems = IPython.__version__.split(".")
    4250    vmaj = int(vitems[0])
    43     vmin = int(vitems[1])
    44     if vmaj == 0:
    45         if vmin >= 11:
    46             ipshell = _main011()
    47         else:
    48             ipshell = _main010()
     51    if vmaj >= 5:
     52        ipshell = _main500()
    4953    else:
    5054        ipshell = _main011()
    5155    ipshell()
    52 
     56   
    5357except ImportError:
    5458    banner =  "No ipython found. Running standard python"
Note: See TracChangeset for help on using the changeset viewer.