mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05:09:23 +01:00
Cooler stackTrace.
This commit is contained in:
parent
2434bdd063
commit
a37129a7c7
16
src/utils.py
16
src/utils.py
@ -693,8 +693,20 @@ def mungeEmailForWeb(s):
|
||||
s = s.replace('.', ' DOT ')
|
||||
return s
|
||||
|
||||
def stackTrace():
|
||||
traceback.print_stack(sys._getframe())
|
||||
def stackTrace(frame=None, compact=False):
|
||||
if frame is None:
|
||||
frame = sys._getframe()
|
||||
if compact:
|
||||
L = []
|
||||
while frame:
|
||||
lineno = frame.f_lineno
|
||||
funcname = frame.f_code.co_name
|
||||
filename = os.path.basename(frame.f_code.co_filename)
|
||||
L.append('[%s|%s|%s]' % (filename, funcname, lineno))
|
||||
frame = frame.f_back
|
||||
return textwrap.fill(' '.join(L))
|
||||
else:
|
||||
return traceback.format_stack(frame)
|
||||
|
||||
class AtomicFile(file):
|
||||
"""Used for files that need to be atomically written -- i.e., if there's a
|
||||
|
Loading…
Reference in New Issue
Block a user