� ɍ�Xc @ s� d d l Te d � Z e d � Z e d � Z e d � Z e d � Z e d � Z e d � Z d d l m Z d d l m Z d d l Z d d l Z d e f d � � YZ d d e e e j e d � Z d f d � � YZ e e e e d � Z d � Z d S( i����( t *i i i i i i i� ( t Enum( t datetimeNt TsLevelc B s, e Z e Z e Z e Z e Z e Z e Z RS( ( t __name__t __module__t _sage_const_0t Silentt _sage_const_1t StackInfot _sage_const_2t Bodyt _sage_const_3t BodySub1t _sage_const_4t BodySub2t _sage_const_5t Debug( ( ( s lib/utils_sys.pyR s t c C s& | j } t j � } t | � } | t | k r5 d S| | t | } | t } | t } | t } d } | t k r� t t j � � } n d | j | | | | | f GHxu t | t � D]c } | | t | | } | t } | t } | t } d G| Gd G| Gd G| GH| d k r� Pq� q� Wd S( s= This is a utility to implement a time-stamp debugging in any function Whenever this function is called it prints the actual timestamp together with traceback information. If you don't see this well formatted type sage: print print_time_tb.__doc__ INPUT (all optional keywords): - "Text": string describing the code position - "Info": string containing further information (for instance on elapse time) - "MaxDepth": integer representing the number of traceback steps (top down) to be printed - "Offset": integer representing the number of traceback steps (top down) to be ignored - "Level": Constants with integer value (substitutes enum type): classifies the position of invocation. The following values are possible: constant integer usage -------------------------------------------------------------------------------------------------- TsLevel.Silent: 0, a message to be printed always TsLevel.StackInfo: 1, indicating function / method entry or exit. typical Text = "Begin", "End" TsLevel.Body: 2, indicating a position in the Body of a function / method TsLevel.BodySub1: 3, similar to the former but subordinary to it TsLevel.BodySub2: 4, similar to the former but subordinary to it TsLevel.Debug: 5, Debug message - "ShowDateTime": boolean (Default = True). If set to False the date and time part of the message is supressed OUTPUT: only prints, no return value EXAMPLES: sage: print_time_tb( Text="Hello", Info="Test" ) L: Silent Time 2016-10-06 18:30:22.574296 Test Hello In: <module> Line: 1 sage: using the Level option sage: print_time_tb( Text="Hello", Info="Test", Level = TsLevel.StackInfo ) L: StackInfo Time 2016-10-06 18:31:58.569208 Test Hello In: <module> Line: 1 sage: using the MaxDepth option sage: sage: print_time_tb( Text="Hello", Info="Test", MaxDepth = 2, Level = TsLevel.StackInfo ) L: StackInfo Time 2016-10-06 18:32:21.537412 Test Hello In: <module> Line: 1 ---> run_code In: /opt/sage/sage-6.9-i686-Linux/local/lib/python2.7/site-packages/IPython/core/ interactiveshell.py Line: 3066 sage: print_time_tb( Text="Hello", Info="Test", MaxDepth = 3, Level = TsLevel.StackInfo ) L: StackInfo Time 2016-10-06 18:32:31.292799 Test Hello In: <module> Line: 1 ---> run_code In: /opt/sage/sage-6.9-i686-Linux/local/lib/python2.7/site-packages/IPython/core/ interactiveshell.py Line: 3066 ---> run_ast_nodes In: /opt/sage/sage-6.9-i686-Linux/local/lib/python2.7/site-packages/IPython/core/ interactiveshell.py Line: 3012 using the Offset option sage: print_time_tb( Text="Hello", Info="Test", MaxDepth = 3, Offset = 2, Level = TsLevel.StackInfo ) L: StackInfo Time 2016-10-06 18:33:20.339336 Test Hello In: run_code Line: 3066 ---> run_ast_nodes In: /opt/sage/sage-6.9-i686-Linux/local/lib/python2.7/site-packages/IPython/core/ interactiveshell.py Line: 3012 ---> run_cell In: /opt/sage/sage-6.9-i686-Linux/local/lib/python2.7/site-packages/IPython/core/ interactiveshell.py Line: 2902 AUTHOR - Sebastian Oehms, Oct. 2016 NR s"