ipy_pydb.py
31 lines
| 814 B
| text/x-python
|
PythonLexer
vivainio
|
r439 | import inspect | ||
vivainio
|
r387 | import IPython.ipapi | ||
from IPython.genutils import arg_split | ||||
ip = IPython.ipapi.get() | ||||
vivainio
|
r439 | from IPython import Debugger | ||
vivainio
|
r387 | def call_pydb(self, args): | ||
vivainio
|
r439 | """Invoke pydb with the supplied parameters.""" | ||
try: | ||||
import pydb | ||||
except ImportError: | ||||
raise ImportError("pydb doesn't seem to be installed.") | ||||
if not hasattr(pydb.pydb, "runv"): | ||||
raise ImportError("You need pydb version 1.19 or later installed.") | ||||
vivainio
|
r387 | argl = arg_split(args) | ||
vivainio
|
r388 | # print argl # dbg | ||
vivainio
|
r439 | if len(inspect.getargspec(pydb.runv)[0]) == 2: | ||
pdb = Debugger.Pdb() | ||||
ip.IP.history_saving_wrapper( lambda : pydb.runv(argl, pdb) )() | ||||
else: | ||||
ip.IP.history_saving_wrapper( lambda : pydb.runv(argl) )() | ||||
vivainio
|
r387 | |||
ip.expose_magic("pydb",call_pydb) | ||||
vivainio
|
r439 | |||