From 7ba4b0a21b0bb2efe0523bec0c1db07771816347 Mon Sep 17 00:00:00 2001 From: Bernardas Date: Wed, 15 Mar 2017 07:50:31 +0000 Subject: [PATCH] add support for embeded ptpython shell --- scrapy/utils/console.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/scrapy/utils/console.py b/scrapy/utils/console.py index 1888d9599..a9d73aada 100644 --- a/scrapy/utils/console.py +++ b/scrapy/utils/console.py @@ -31,6 +31,15 @@ def _embed_bpython_shell(namespace={}, banner=''): bpython.embed(locals_=namespace, banner=banner) return wrapper +def _embed_ptpython_shell(namespace={}, banner=''): + """Start a ptpython shell""" + import ptpython.repl + @wraps(_embed_ptpython_shell) + def wrapper(namespace=namespace, banner=''): + print(banner) + ptpython.repl.embed(locals=namespace) + return wrapper + def _embed_standard_shell(namespace={}, banner=''): """Start a standard python shell""" import code @@ -49,7 +58,8 @@ def _embed_standard_shell(namespace={}, banner=''): DEFAULT_PYTHON_SHELLS = OrderedDict([ ('ipython', _embed_ipython_shell), ('bpython', _embed_bpython_shell), - ( 'python', _embed_standard_shell), + ('ptpython', _embed_ptpython_shell), + ('python', _embed_standard_shell), ]) def get_shell_embed_func(shells=None, known_shells=None):