Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for the nifty ptpython shell. #133

Merged
merged 1 commit into from Feb 13, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions pudb/debugger.py
Expand Up @@ -1672,6 +1672,8 @@ def run_external_cmdline(w, size, key):
runner = shell.run_ipython_shell
elif shell.HAVE_BPYTHON and CONFIG["shell"] == "bpython":
runner = shell.run_bpython_shell
elif shell.HAVE_PTPYTHON and CONFIG["shell"] == "ptpython":
runner = shell.run_ptpython_shell
else:
runner = shell.run_classic_shell

Expand Down
2 changes: 1 addition & 1 deletion pudb/settings.py
Expand Up @@ -203,7 +203,7 @@ def _update_config(check_box, new_state, option_newvalue):

shell_info = urwid.Text("This is the shell that will be "
"used when you hit '!'.\n")
shells = ["internal", "classic", "ipython", "bpython"]
shells = ["internal", "classic", "ipython", "bpython", "ptpython"]

shell_rb_group = []
shell_rbs = [
Expand Down
15 changes: 15 additions & 0 deletions pudb/shell.py
Expand Up @@ -12,6 +12,13 @@
else:
HAVE_BPYTHON = True

try:
from prompt_toolkit.contrib.repl import embed as ptpython_embed
except ImportError:
HAVE_PTPYTHON = False
else:
HAVE_PTPYTHON = True


# {{{ readline wrangling

Expand Down Expand Up @@ -141,6 +148,14 @@ def run_ipython_shell_v11(locals, globals, first_time):
_update_ns(shell, old_locals, old_globals)


def run_ptpython_shell(locals, globals, first_time):
## Use the default ptpython history:
import os
history_filename = os.path.expanduser('~/.ptpython_history')
ptpython_embed(globals.copy(), locals.copy(),
history_filename=history_filename)


def _update_ns(shell, locals, globals):
'''Update the IPython 0.11 namespace at every visit'''

Expand Down