mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-18 22:51:01 +01:00
Added docstrings.
This commit is contained in:
parent
8d620207ea
commit
5b5f8a1d2b
10
src/debug.py
10
src/debug.py
@ -106,6 +106,7 @@ priorityColors.setdefault('')
|
|||||||
lastTimes = [time.time()-1] * 10
|
lastTimes = [time.time()-1] * 10
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
|
"""Resets the various file descriptors kept open by this module."""
|
||||||
global _errorfd, _debugfd, _tracefd
|
global _errorfd, _debugfd, _tracefd
|
||||||
_errorfd.flush()
|
_errorfd.flush()
|
||||||
_errorfd.close()
|
_errorfd.close()
|
||||||
@ -118,6 +119,7 @@ def reset():
|
|||||||
_tracefd = file(_errorfd.name, 'w')
|
_tracefd = file(_errorfd.name, 'w')
|
||||||
|
|
||||||
def exit(i=-1):
|
def exit(i=-1):
|
||||||
|
"""Makes sure to actually exit."""
|
||||||
class E(Exception):
|
class E(Exception):
|
||||||
pass
|
pass
|
||||||
if deadlyExceptions:
|
if deadlyExceptions:
|
||||||
@ -136,8 +138,7 @@ def _writeNewline(fd, s):
|
|||||||
fd.write(os.linesep)
|
fd.write(os.linesep)
|
||||||
|
|
||||||
def recoverableError(msg):
|
def recoverableError(msg):
|
||||||
"""Called with errors that are not critical.
|
"""Called with errors that are not critical."""
|
||||||
"""
|
|
||||||
if stderr:
|
if stderr:
|
||||||
if colorterm:
|
if colorterm:
|
||||||
sys.stderr.write(ansi.BOLD + ansi.RED)
|
sys.stderr.write(ansi.BOLD + ansi.RED)
|
||||||
@ -193,10 +194,12 @@ def recoverableException(type='detailed'):
|
|||||||
_errorfd.flush()
|
_errorfd.flush()
|
||||||
|
|
||||||
def unrecoverableException():
|
def unrecoverableException():
|
||||||
|
"""Logs the most recent exception and then exits."""
|
||||||
recoverableException()
|
recoverableException()
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
|
||||||
def msg(s, priority='low'):
|
def msg(s, priority='low'):
|
||||||
|
"""Logs a message s with the appropriate priority."""
|
||||||
if priorities[priority] >= priorities[minimumPriority]:
|
if priorities[priority] >= priorities[minimumPriority]:
|
||||||
if stderr:
|
if stderr:
|
||||||
if colorterm:
|
if colorterm:
|
||||||
@ -209,13 +212,16 @@ def msg(s, priority='low'):
|
|||||||
_debugfd.flush()
|
_debugfd.flush()
|
||||||
|
|
||||||
def printf(msg):
|
def printf(msg):
|
||||||
|
"""Used for simple printf debugging. Can be turned off via PRINTF."""
|
||||||
if PRINTF:
|
if PRINTF:
|
||||||
print '*** ' + str(msg)
|
print '*** ' + str(msg)
|
||||||
|
|
||||||
def methodNamePrintf(obj, methodName):
|
def methodNamePrintf(obj, methodName):
|
||||||
|
"""Does a debug.printf with the appropriate method name."""
|
||||||
printf('%s: %s' % (obj.__class__.__name__, methodName))
|
printf('%s: %s' % (obj.__class__.__name__, methodName))
|
||||||
|
|
||||||
def exnToString(e):
|
def exnToString(e):
|
||||||
|
"""Turns a simple exception instance into a string (better than str(e))"""
|
||||||
return '%s: %s' % (e.__class__.__name__, e)
|
return '%s: %s' % (e.__class__.__name__, e)
|
||||||
|
|
||||||
def tracer(frame, event, _):
|
def tracer(frame, event, _):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user