<reponame>poma/parse-tweets<filename>util.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import traceback, sys
    
def full_stack():
    exc = sys.exc_info()[0]
    stack = traceback.extract_stack()[:-1]  # last one would be full_stack()
    if not exc is None:  # i.e. if an exception is present
        del stack[-1]       # remove call of full_stack, the printed exception
                            # will contain the caught exception caller instead
    trc = 'Traceback (most recent call last):\n'
    stackstr = trc + ''.join(traceback.format_list(stack))
    if not exc is None:
         stackstr += '  ' + traceback.format_exc().lstrip(trc)
    return stackstr

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import traceback, sys
    
def full_stack():
    exc = sys.exc_info()[0]
    stack = traceback.extract_stack()[:-1]  # last one would be full_stack()
    if not exc is None:  # i.e. if an exception is present
        del stack[-1]       # remove call of full_stack, the printed exception
                            # will contain the caught exception caller instead
    trc = 'Traceback (most recent call last):\n'
    stackstr = trc + ''.join(traceback.format_list(stack))
    if not exc is None:
         stackstr += '  ' + traceback.format_exc().lstrip(trc)
    return stackstr
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # last one would be full_stack() # i.e. if an exception is present # remove call of full_stack, the printed exception # will contain the caught exception caller instead