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)
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__
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
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()
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()
def configure(repl): path = os.path.join(config_dir, 'config.py') if os.path.exists(path): run_config(repl, path)
def configure(repl): if os.path.exists(config_file): run_config(repl, config_file)
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())
def configure(repl): path = config_dir / "config.py" if path.exists(): run_config(repl, str(path))
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 = "> "
def configure(*args, **kwargs): if os.path.exists(os.path.expanduser('~/.ptpython/config.py')): run_config(*args, **kwargs)