Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def start_repl(loop: asyncio.AbstractEventLoop):
"""
Start the REPL and attach it to the provided event loop
:param loop:
:return:
"""
config_file = environ.get('config_file', DEFAULT_CONFIG_FILE)
if os.path.exists(config_file):
configure = partial(run_config, config_file=config_file)
else:
configure = default_configure
manager_class = get_class(environ['connection_manager'])
manager = manager_class(loop)
yield from embed(
globals={},
locals={
'connect': manager,
'connect_to': manager,
'connections': ManagesNamesProxy(manager),
},
title='AutoBahn-Python REPL',
return_asyncio_coroutine=True,
patch_stdout=True,
configure=configure,
history_filename=environ.get('history_file', DEFAULT_HISTORY_FILE)
def configure(repl):
path = os.path.join(config_dir, 'config.py')
if os.path.exists(path):
run_config(repl, path)
def configure(repl):
path = os.path.join(config_dir, 'config.py')
if os.path.exists(path):
run_config(repl, path)
def run_ptpython(imported_objects, vi_mode=False):
from ptpython.repl import embed, run_config
history_filename = os.path.expanduser('~/.ptpython_history')
embed(globals=imported_objects, history_filename=history_filename,
vi_mode=vi_mode, configure=run_config)
def configure(repl):
path = config_dir / "config.py"
if path.exists():
run_config(repl, str(path))
def run_ptipython(imported_objects, vi_mode=False):
from ptpython.repl import run_config
from ptpython.ipython import embed
history_filename = os.path.expanduser('~/.ptpython_history')
embed(user_ns=imported_objects, history_filename=history_filename,
vi_mode=vi_mode, configure=run_config)
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()