Skip to content

Commit 0837cae

Browse files
authored
Add support for ptpython config and history files
This uses the official/upstream way of finding the config and history file, since ~/.ptpython/config.py is deprecated. It also uses the global ones, though it can be easily extended to support per project config and history. But that's for a rainy day. Fixes jacquerie#7 and jacquerie#13.
1 parent 515a502 commit 0837cae

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

flask_shell_ptpython.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ def shell_command():
2020
without having to manually configure the application.
2121
"""
2222
from flask.globals import _app_ctx_stack
23-
from ptpython.repl import embed
23+
from ptpython.repl import embed, run_config
24+
from ptpython.entry_points.run_ptpython import create_parser, get_config_and_history_file
2425

2526
app = _app_ctx_stack.top.app
2627
ctx = {}
@@ -34,4 +35,15 @@ def shell_command():
3435

3536
ctx.update(app.make_shell_context())
3637

37-
embed(globals=ctx)
38+
config_file, history_filename = get_config_and_history_file(
39+
create_parser().parse_args([])
40+
)
41+
42+
def configure(repl):
43+
run_config(repl, config_file=config_file)
44+
45+
embed(
46+
globals=ctx,
47+
history_filename=history_filename,
48+
configure=configure
49+
)

0 commit comments

Comments
 (0)