| 1 | #!/usr/bin/env python
|
|---|
| 2 | import os
|
|---|
| 3 |
|
|---|
| 4 | def _main500():
|
|---|
| 5 | from IPython.terminal.prompts import Prompts, Token
|
|---|
| 6 | from traitlets.config.loader import Config
|
|---|
| 7 |
|
|---|
| 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 = '')
|
|---|
| 22 | return ipshell
|
|---|
| 23 |
|
|---|
| 24 | def _main011():
|
|---|
| 25 | from IPython.config.loader import Config
|
|---|
| 26 | cfg = Config()
|
|---|
| 27 | prompt_config = cfg.PromptManager
|
|---|
| 28 | prompt_config.in_template = 'ASAP> '
|
|---|
| 29 | prompt_config.out_template = 'asap>: '
|
|---|
| 30 | cfg.InteractiveShell.autoindent = True
|
|---|
| 31 | cfg.InteractiveShell.autocall = 2
|
|---|
| 32 | cfg.InteractiveShell.magic_pprint = True
|
|---|
| 33 | cfg.InteractiveShell.use_readline=True
|
|---|
| 34 | cfg.InteractiveShell.confirm_exit=False
|
|---|
| 35 | cfg.InteractiveShell.xmode='Plain'
|
|---|
| 36 | try:
|
|---|
| 37 | from IPython.terminal.embed import InteractiveShellEmbed
|
|---|
| 38 | except ImportError:
|
|---|
| 39 | from IPython.frontend.terminal.embed import InteractiveShellEmbed
|
|---|
| 40 | ipshell = InteractiveShellEmbed(config=cfg,
|
|---|
| 41 | banner1 = welcome(),
|
|---|
| 42 | exit_msg = '')
|
|---|
| 43 | return ipshell
|
|---|
| 44 |
|
|---|
| 45 | try:
|
|---|
| 46 | os.system('clear')
|
|---|
| 47 | import IPython
|
|---|
| 48 | from asap import *
|
|---|
| 49 | vitems = IPython.__version__.split(".")
|
|---|
| 50 | vmaj = int(vitems[0])
|
|---|
| 51 | if vmaj >= 5:
|
|---|
| 52 | ipshell = _main500()
|
|---|
| 53 | else:
|
|---|
| 54 | ipshell = _main011()
|
|---|
| 55 | ipshell()
|
|---|
| 56 |
|
|---|
| 57 | except ImportError:
|
|---|
| 58 | banner = "No ipython found. Running standard python"
|
|---|
| 59 | import code
|
|---|
| 60 | from asap import *
|
|---|
| 61 | code.interact(banner, local=locals())
|
|---|