How to use the ptpython.repl function in ptpython

To help you get started, we’ve selected a few ptpython examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NixOS / nixpkgs / nixos / lib / test-driver / test-driver.py View on Github external
def run_tests():
    tests = os.environ.get("tests", None)
    if tests is not None:
        with log.nested("running the VM test script"):
            try:
                exec(tests)
            except Exception as e:
                eprint("error: {}".format(str(e)))
                sys.exit(1)
    else:
        ptpython.repl.embed(locals(), globals())

    # TODO: Collect coverage data

    for machine in machines:
        if machine.is_up():
            machine.execute("sync")

    if nr_tests != 0:
        log.log("{} out of {} tests succeeded".format(nr_succeeded, nr_tests))
github nagareproject / core / nagare / admin / shell.py View on Github external
try:
            from ptpython import repl, prompt_style
        except ImportError:
            pass
        else:
            def configure(repl):
                class NagarePrompt(prompt_style.ClassicPrompt):
                    def in_tokens(self, cli):
                        return [(prompt_style.Token.Prompt, 'Nagare%s>>> ' % prompt)]

                repl.all_prompt_styles['nagare'] = NagarePrompt()
                repl.prompt_style = 'nagare'

            print banner

            repl.embed(
                globals(), ns,
                history_filename=os.path.expanduser('~/.nagarehistory'),
                configure=configure
            )
            return

        try:
            from bpython import curtsies, embed
        except ImportError:
            pass
        else:
            class FullCurtsiesRepl(curtsies.FullCurtsiesRepl):
                def __init__(self, config, *args, **kw):
                    config.hist_file = os.path.expanduser('~/.nagarehistory')
                    super(FullCurtsiesRepl, self).__init__(config, *args, **kw)
github prompt-toolkit / python-prompt-toolkit / prompt_toolkit / contrib / repl.py View on Github external
def embed(*a, **kw):
        """
        DEPRECATED. Only for backwards compatibility.
        Please call ptpython.repl.embed directly!
        """
        ptpython.repl.embed(*a, **kw)
except ImportError as e: