Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-release > by-pkgid > ecc026b61096e2959ba01e3826059e7c > files > 59

ipython-doc-7.2.0-3.mga7.noarch.rpm

"""This is an example that shows how to create new prompts for IPython
"""

from IPython.terminal.prompts import Prompts, Token
import os

class MyPrompt(Prompts):

     def in_prompt_tokens(self, cli=None):
         return [(Token, os.getcwd()),
                 (Token.Prompt, '>>>')]

def load_ipython_extension(shell):
    new_prompts = MyPrompt(shell)
    new_prompts.old_prompts = shell.prompts
    shell.prompts = new_prompts

def unload_ipython_extension(shell):
    if not hasattr(shell.prompts, 'old_prompts'):
        print("cannot unload")
    else:
        shell.prompts = shell.prompts.old_prompts