本文整理汇总了Python中repr.repr方法的典型用法代码示例。如果您正苦于以下问题:Python repr.repr方法的具体用法?Python repr.repr怎么用?Python repr.repr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类repr
的用法示例。
在下文中一共展示了repr.repr方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trace_dispatch
# 需要导入模块: import repr [as 别名]
# 或者: from repr import repr [as 别名]
def trace_dispatch(self, frame, event, arg):
if self.quitting:
return # None
if event == 'line':
return self.dispatch_line(frame)
if event == 'call':
return self.dispatch_call(frame, arg)
if event == 'return':
return self.dispatch_return(frame, arg)
if event == 'exception':
return self.dispatch_exception(frame, arg)
if event == 'c_call':
return self.trace_dispatch
if event == 'c_exception':
return self.trace_dispatch
if event == 'c_return':
return self.trace_dispatch
print 'bdb.Bdb.dispatch: unknown debugging event:', repr(event)
return self.trace_dispatch
示例2: format_stack_entry
# 需要导入模块: import repr [as 别名]
# 或者: from repr import repr [as 别名]
def format_stack_entry(self, frame_lineno, lprefix=': '):
import linecache, repr
frame, lineno = frame_lineno
filename = self.canonic(frame.f_code.co_filename)
s = '%s(%r)' % (filename, lineno)
if frame.f_code.co_name:
s = s + frame.f_code.co_name
else:
s = s + "<lambda>"
if '__args__' in frame.f_locals:
args = frame.f_locals['__args__']
else:
args = None
if args:
s = s + repr.repr(args)
else:
s = s + '()'
if '__return__' in frame.f_locals:
rv = frame.f_locals['__return__']
s = s + '->'
s = s + repr.repr(rv)
line = linecache.getline(filename, lineno)
if line: s = s + lprefix + line.strip()
return s
示例3: format_stack_entry
# 需要导入模块: import repr [as 别名]
# 或者: from repr import repr [as 别名]
def format_stack_entry(self, frame_lineno, lprefix=': '):
import linecache, repr
frame, lineno = frame_lineno
filename = self.canonic(frame.f_code.co_filename)
s = '%s(%r)' % (filename, lineno)
if frame.f_code.co_name:
s = s + frame.f_code.co_name
else:
s = s + "<lambda>"
if '__args__' in frame.f_locals:
args = frame.f_locals['__args__']
else:
args = None
if args:
s = s + repr.repr(args)
else:
s = s + '()'
if '__return__' in frame.f_locals:
rv = frame.f_locals['__return__']
s = s + '->'
s = s + repr.repr(rv)
line = linecache.getline(filename, lineno, frame.f_globals)
if line: s = s + lprefix + line.strip()
return s
# The following two methods can be called by clients to use
# a debugger to debug a statement, given as a string.
示例4: test_longer_repr
# 需要导入模块: import repr [as 别名]
# 或者: from repr import repr [as 别名]
def test_longer_repr():
from repr import repr as trepr
a = '1234567890'* 7
ar = "'1234567890123456789012345678901234567890123456789012345678901234567890'"
a_trunc = "'123456789012...8901234567890'"
nt.assert_equal(trepr(a), a_trunc)
# The creation of our tracer modifies the repr module's repr function
# in-place, since that global is used directly by the stdlib's pdb module.
t = debugger.Tracer()
nt.assert_equal(trepr(a), ar)
示例5: do_list
# 需要导入模块: import repr [as 别名]
# 或者: from repr import repr [as 别名]
def do_list(self, arg):
self.lastcmd = 'list'
last = None
if arg:
try:
x = eval(arg, {}, {})
if type(x) == type(()):
first, last = x
first = int(first)
last = int(last)
if last < first:
# Assume it's a count
last = first + last
else:
first = max(1, int(x) - 5)
except:
print('*** Error in argument:', repr(arg))
return
elif self.lineno is None:
first = max(1, self.curframe.f_lineno - 5)
else:
first = self.lineno + 1
if last is None:
last = first + 10
self.print_list_lines(self.curframe.f_code.co_filename, first, last)
# vds: >>
lineno = first
filename = self.curframe.f_code.co_filename
self.shell.hooks.synchronize_with_editor(filename, lineno, 0)
# vds: <<
示例6: configure_logging
# 需要导入模块: import repr [as 别名]
# 或者: from repr import repr [as 别名]
def configure_logging(suffix=None):
logging.config.eval = _security_logging_config_monkeypatched_eval
file_name = ('logging.conf' if suffix is None
else 'logging-{0}.conf'.format(suffix))
file_paths = [os.path.join(config_dir, file_name)
for config_dir in (ETC_DIR, USER_DIR)]
for path in file_paths:
if path in _loaded_configuration_paths:
_LOGGER.warning('ignored attempt to load logging configuration '
'file %r that has already been used', path)
continue
try:
_try_reading(path)
except EnvironmentError:
pass
else:
try:
logging.config.fileConfig(path, disable_existing_loggers=False)
except AMQPConnectionError:
raise RuntimeError('error while configuring logging, '
'using settings from configuration file {0!r}:\n'
'unable to establish '
'connection with RabbitMQ server\n{1}'
.format(path, traceback.format_exc()))
except Exception:
raise RuntimeError('error while configuring logging, '
'using settings from configuration file {0!r}:\n{1}'
.format(path, traceback.format_exc()))
else:
_LOGGER.info('logging configuration loaded from %r', path)
_loaded_configuration_paths.add(path)
if not _loaded_configuration_paths:
raise RuntimeError('logging configuration not loaded: '
'could not open any of the files: {0}'
.format(', '.join(map(repr, file_paths))))
# TODO: doc and maybe some tests?
示例7: format_stack_entry
# 需要导入模块: import repr [as 别名]
# 或者: from repr import repr [as 别名]
def format_stack_entry(self, frame_lineno, lprefix=': '):
import linecache, repr
frame, lineno = frame_lineno
filename = self.canonic(frame.f_code.co_filename)
s = '%s(%r)' % (filename, lineno)
if frame.f_code.co_name:
s = s + frame.f_code.co_name
else:
s = s + "<lambda>"
if '__args__' in frame.f_locals:
args = frame.f_locals['__args__']
else:
args = None
if args:
s = s + repr.repr(args)
else:
s = s + '()'
if '__return__' in frame.f_locals:
rv = frame.f_locals['__return__']
s = s + '->'
s = s + repr.repr(rv)
line = linecache.getline(filename, lineno)
if line: s = s + lprefix + line.strip()
return s
# The following two methods can be called by clients to use
# a debugger to debug a statement, given as a string.