本文整理汇总了Python中IPython.core.debugger.Pdb.completenames方法的典型用法代码示例。如果您正苦于以下问题:Python Pdb.completenames方法的具体用法?Python Pdb.completenames怎么用?Python Pdb.completenames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPython.core.debugger.Pdb
的用法示例。
在下文中一共展示了Pdb.completenames方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IPdbKernel
# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import completenames [as 别名]
class IPdbKernel(Kernel):
implementation = 'IPdbKernel'
implementation_version = '0.1'
language = 'IPdb'
language_version = '0.1'
language_info = {'mimetype': 'text/plain'}
banner = "IPython debugger kernel"
def __init__(self, **kwargs):
Kernel.__init__(self, **kwargs)
# Instantiate IPython.core.debugger.Pdb here, pass it a phony
# stdout that provides a dummy flush() method and a write() method
# that internally sends data using a function so that it can
# be initialized to use self.send_response()
write_func = lambda s: self.send_response(self.iopub_socket,
'stream',
{'name': 'stdout',
'text': s})
sys.excepthook = functools.partial(BdbQuit_excepthook,
excepthook=sys.excepthook)
self.debugger = Pdb(stdout=PhonyStdout(write_func))
self.debugger.set_trace(sys._getframe().f_back)
def do_execute(self, code, silent, store_history=True,
user_expressions=None, allow_stdin=False):
if not code.strip():
return {'status': 'ok', 'execution_count': self.execution_count,
'payload': [], 'user_expressions': {}}
# Process command:
line = self.debugger.precmd(code)
stop = self.debugger.onecmd(line)
stop = self.debugger.postcmd(stop, line)
if stop:
self.debugger.postloop()
return {'status': 'ok', 'execution_count': self.execution_count,
'payload': [], 'user_expression': {}}
def do_complete(self, code, cursor_pos):
code = code[:cursor_pos]
default = {'matches': [], 'cursor_start': 0,
'cursor_end': cursor_pos, 'metadata': dict(),
'status': 'ok'}
if not code or code[-1] == ' ':
return default
# Run Pdb.completenames on code, extend matches with results:
matches = self.debugger.completenames(code)
if not matches:
return default
return {'matches': sorted(matches), 'cursor_start': cursor_pos-len(code),
'cursor_end': cursor_pos, 'metadata': dict(),
'status': 'ok'}