Skip to content

Commit

Permalink
Add support for ptpython config and history files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
maxnordlund authored Mar 9, 2020
1 parent 515a502 commit 0837cae
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions flask_shell_ptpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def shell_command():
without having to manually configure the application.
"""
from flask.globals import _app_ctx_stack
from ptpython.repl import embed
from ptpython.repl import embed, run_config
from ptpython.entry_points.run_ptpython import create_parser, get_config_and_history_file

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

ctx.update(app.make_shell_context())

embed(globals=ctx)
config_file, history_filename = get_config_and_history_file(
create_parser().parse_args([])
)

def configure(repl):
run_config(repl, config_file=config_file)

embed(
globals=ctx,
history_filename=history_filename,
configure=configure
)

0 comments on commit 0837cae

Please sign in to comment.