本文整理汇总了Python中pdb.line_prefix方法的典型用法代码示例。如果您正苦于以下问题:Python pdb.line_prefix方法的具体用法?Python pdb.line_prefix怎么用?Python pdb.line_prefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pdb
的用法示例。
在下文中一共展示了pdb.line_prefix方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_formatted_stack_entry
# 需要导入模块: import pdb [as 别名]
# 或者: from pdb import line_prefix [as 别名]
def _get_formatted_stack_entry(
self, frame_lineno, prompt_prefix=pdb.line_prefix, frame_index=None
):
frame, lineno = frame_lineno
if frame is self.curframe:
marker = "> "
else:
marker = " "
frame_prefix_width = len(str(len(self.stack)))
if frame_index is None:
frame_index = self.curindex
fmt = "{frame_prefix}{marker}"
lprefix = prompt_prefix # "\n ->" by default
else:
# via/for stack trace
fmt = "{marker}{frame_prefix}"
lprefix = "\n " + (" " * frame_prefix_width)
# Format stack index (keeping same width across stack).
frame_prefix = ("[%%%dd] " % frame_prefix_width) % frame_index
marker_frameno = fmt.format(marker=marker, frame_prefix=frame_prefix)
return marker_frameno + self.format_stack_entry(frame_lineno, lprefix)
示例2: do_hf_list
# 需要导入模块: import pdb [as 别名]
# 或者: from pdb import line_prefix [as 别名]
def do_hf_list(self, arg):
for frame_lineno in self.hidden_frames:
print(self.format_stack_entry(frame_lineno, pdb.line_prefix),
file=self.stdout)
示例3: print_stack_entry
# 需要导入模块: import pdb [as 别名]
# 或者: from pdb import line_prefix [as 别名]
def print_stack_entry(
self, frame_lineno, prompt_prefix=pdb.line_prefix, frame_index=None
):
print(
self._get_formatted_stack_entry(frame_lineno, prompt_prefix, frame_index),
file=self.stdout,
)
示例4: find_function
# 需要导入模块: import pdb [as 别名]
# 或者: from pdb import line_prefix [as 别名]
def find_function(funcname, filename):
cre = re.compile(r'def\s+%s\s*[(]' % re.escape(funcname))
try:
fp = open(filename)
except IOError:
return None
# consumer of this info expects the first line to be 1
lineno = 1
answer = None
while 1:
line = fp.readline()
if line == '':
break
if cre.match(line):
answer = funcname, filename, lineno
break
lineno = lineno + 1
fp.close()
return answer
# Interaction prompt line will separate file and call info from code
# text using value of line_prefix string. A newline and arrow may
# be to your liking. You can set it once pdb is imported using the
# command "pdb.line_prefix = '\n% '".
# line_prefix = ': ' # Use this to get the old situation back
示例5: print_stack_entry
# 需要导入模块: import pdb [as 别名]
# 或者: from pdb import line_prefix [as 别名]
def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix):
frame, lineno = frame_lineno
if frame is self.curframe:
print >>self.stdout, '>',
else:
print >>self.stdout, ' ',
print >>self.stdout, self.format_stack_entry(frame_lineno,
prompt_prefix)
# Help methods (derived from pdb.doc)
示例6: __repr__
# 需要导入模块: import pdb [as 别名]
# 或者: from pdb import line_prefix [as 别名]
def __repr__(self):
return self
# Interaction prompt line will separate file and call info from code
# text using value of line_prefix string. A newline and arrow may
# be to your liking. You can set it once pdb is imported using the
# command "pdb.line_prefix = '\n% '".
# line_prefix = ': ' # Use this to get the old situation back
示例7: print_stack_entry
# 需要导入模块: import pdb [as 别名]
# 或者: from pdb import line_prefix [as 别名]
def print_stack_entry(self, frame_lineno, prompt_prefix=line_prefix):
frame, lineno = frame_lineno
if frame is self.curframe:
prefix = '> '
else:
prefix = ' '
self.message(prefix +
self.format_stack_entry(frame_lineno, prompt_prefix))
# Provide help