##// END OF EJS Templates
please linter
Matthias Bussonnier -
Show More
@@ -1,25 +1,22 b''
1 """This is an example that shows how to create new prompts for IPython
1 """This is an example that shows how to create new prompts for IPython
2 """
2 """
3
3
4 from IPython.terminal.prompts import Prompts, Token
4 from IPython.terminal.prompts import Prompts, Token
5 import os
5 import os
6
6
7 class MyPrompt(Prompts):
7 class MyPrompt(Prompts):
8
8
9 def in_prompt_tokens(self):
9 def in_prompt_tokens(self):
10 return [
10 return [(Token, os.getcwd()), (Token.Prompt, ">>>")]
11 (Token, os.getcwd()),
12 (Token.Prompt, ">>>")
13 ]
14
11
15
12
16 def load_ipython_extension(shell):
13 def load_ipython_extension(shell):
17 new_prompts = MyPrompt(shell)
14 new_prompts = MyPrompt(shell)
18 new_prompts.old_prompts = shell.prompts
15 new_prompts.old_prompts = shell.prompts
19 shell.prompts = new_prompts
16 shell.prompts = new_prompts
20
17
21 def unload_ipython_extension(shell):
18 def unload_ipython_extension(shell):
22 if not hasattr(shell.prompts, 'old_prompts'):
19 if not hasattr(shell.prompts, 'old_prompts'):
23 print("cannot unload")
20 print("cannot unload")
24 else:
21 else:
25 shell.prompts = shell.prompts.old_prompts
22 shell.prompts = shell.prompts.old_prompts
General Comments 0
You need to be logged in to leave comments. Login now