Skip to content

Commit

Permalink
Added support for the nifty ptpython shell.
Browse files Browse the repository at this point in the history
  • Loading branch information
pvaret committed Feb 13, 2015
1 parent e9c8dd3 commit dc3a6c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
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

0 comments on commit dc3a6c2

Please sign in to comment.