Exemplo n.º 1
0
 def configure(repl):
     path = os.path.join(config_dir, 'conf.cfg')
     if os.path.exists(path):
         load_config(repl, path)
     path = os.path.join(config_dir, 'config.py')
     if os.path.exists(path):
         run_config(repl, path)
Exemplo n.º 2
0
        def configure(repl) -> None:
            if os.path.exists(config_file):
                run_config(repl, config_file)
            else:
                # from https://github.com/prompt-toolkit/ptpython/blob/master/examples/ptpython_config/config.py
                # Ask for confirmation on exit.
                repl.confirm_exit = False

            # embedded in other applications.
            repl.title = "Skepticoin %s " % __version__
Exemplo n.º 3
0
        def configure(repl) -> None:
            if os.path.exists(config_file):
                run_config(repl, config_file)

            # Adjust colors if dark/light background flag has been given.
            if a.light_bg:
                repl.min_brightness = 0.0
                repl.max_brightness = 0.60
            elif a.dark_bg:
                repl.min_brightness = 0.60
                repl.max_brightness = 1.0
Exemplo n.º 4
0
def shell(globals_, locals_):
    """
    Customized pypython.repl.
    """
    # Create REPL.
    repl = PythonRepl(
        get_globals=lambda : globals_,
        get_locals=lambda : locals_,
        history_filename=os.path.expanduser("~/.pyhistory.shell"),
    )
    run_config(repl)

    with DummyContext():
        repl.run()
Exemplo n.º 5
0
def shell(globals_, locals_):
    """
    Customized pypython.repl.
    """
    # Create REPL.
    repl = PythonRepl(
        get_globals=lambda: globals_,
        get_locals=lambda: locals_,
        history_filename=os.path.expanduser("~/.pyhistory.shell"),
    )
    run_config(repl)

    with DummyContext():
        repl.run()
Exemplo n.º 6
0
 def configure(repl):
     path = os.path.join(config_dir, 'config.py')
     if os.path.exists(path):
         run_config(repl, path)
Exemplo n.º 7
0
 def configure(repl):
     if os.path.exists(config_file):
         run_config(repl, config_file)
Exemplo n.º 8
0
def _ptpython_configure(repl):
    from ptpython.repl import run_config

    path = _ptpython_conf_dir / "config.py"
    if path.exists():
        run_config(repl, path.as_posix())
Exemplo n.º 9
0
Arquivo: konch.py Projeto: brl0/konch
 def configure(repl):
     path = config_dir / "config.py"
     if path.exists():
         run_config(repl, str(path))
Exemplo n.º 10
0
import sys
from importlib.util import find_spec
from os.path import join
from os import getenv

# embed ptpython if it is installed and isn't the current REPL
if "ptpython" not in getenv("_") and find_spec("ptpython"):
    from ptpython.repl import embed, run_config
    from appdirs import user_config_dir, user_data_dir

    config_file = join(
        getenv("PTPYTHON_CONFIG_HOME",
               user_config_dir("ptpython", "prompt_toolkit")), "config.py")
    history_file = join(user_data_dir("ptpython", "prompt_toolkit"), "history")
    sys.exit(
        embed(globals(), locals(), lambda repl: run_config(repl, config_file),
              False, history_file))
# if not customize standard python REPL
else:
    # make primary prompt shorter because ~/.inputrc shows vi editing mode
    sys.ps1 = "> "
Exemplo n.º 11
0
 def configure(*args, **kwargs):
     if os.path.exists(os.path.expanduser('~/.ptpython/config.py')):
         run_config(*args, **kwargs)
Exemplo n.º 12
0
 def configure(repl):
     path = config_dir / "config.py"
     if path.exists():
         run_config(repl, str(path))
Exemplo n.º 13
0
 def configure(*args, **kwargs):
     if os.path.exists(os.path.expanduser('~/.ptpython/config.py')):
         run_config(*args, **kwargs)