Source code for tagit.debug
"""Debug helpers.
use like so:
>>> from debug import doDebug
>>> doDebug(locals())
Whenever you do this, you'll be dropped into a shell for debugging. Exit the shell with ctrl+d
You'll have your local variables and many debugging helpers readily imported.
Part of the tagit module.
A copy of the license is provided with the project.
Author: Angela Botros, Summer 2014
Copied from Angela Botros' Master thesis
"""
__all__ = ('debug', 'doDebug')
[docs]def debug(local, abort=False):
"""Enter a debug shell.
In your code, place the following statement
>>> debug(locals())
to enter the debug shell at that point. You'll have all local variables
available, plus some extra modules (see below).
To get the current stack trace, call ``tr.print_stack()``.
Extra modules: code, traceback (tr), os, sys, itertools, copy, time.
"""
import code
import traceback as tr
import os
import sys
import itertools
from copy import copy
import time
loc = locals()
loc.update(local)
code.interact(banner="Debug shell", local=loc)
if abort:
sys.exit(1)
[docs]def doDebug(loc):
"""Start an interactive debug shell.
>>> from debug import doDebug
>>> doDebug(locals())
Whenever you do this, you'll be dropped into a shell for debugging. Exit the shell with ctrl+d
You'll have your local variables and many debugging helpers readily imported.
"""
loc.update(globals())
debug(loc)
## EOF ##