ó õ^‚Rc @ s d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d „ Z g Z d „ Z d „ Z d „ Z d „ Z d „ Z d d „ Z d d „ Z d d d „ ƒ YZ e ƒ j Z d d d d d „ Z d S( sš More comprehensive traceback formatting for Python scripts. To enable this module, do: import cgitb; cgitb.enable() at the top of your script. The optional arguments to enable() are: display - if true, tracebacks are displayed in the web browser logdir - if set, tracebacks are written to files in this directory context - number of lines of source code to show for each stack frame format - 'text' or 'html' controls the output format By default, tracebacks are displayed but not saved, the context is 5 lines and the output format is 'html' (for backwards compatibility with the original use of this module) Alternatively, if you have caught an exception and want cgitb to display it for you, call cgitb.handler(). The optional argument to handler() is a 3-item tuple (etype, evalue, etb) just like the value of sys.exc_info(). The default handler displays output as HTML. iÿÿÿÿNc C s d S( sA Return a string that resets the CGI and browser to a known state.s'
--> --> ( ( ( ( s /usr/lib/python2.7/cgitb.pyt reset$ s c C s | r d | d Sd Sd S( Ns s t ( ( t text( ( s /usr/lib/python2.7/cgitb.pyt small/ s c C s | r d | d Sd Sd S( Ns s R ( ( R ( ( s /usr/lib/python2.7/cgitb.pyt strong5 s c C s | r d | d Sd Sd S( Ns s R ( ( R ( ( s /usr/lib/python2.7/cgitb.pyt grey; s c C sº | | k r d | | f S| | j k r: d | j | f Sd | j k r° | j d } t | ƒ t i ƒ k r‹ | | k r d | | f Sq° t | | ƒ r° d t | | ƒ f Sn d t f S( s9 Find the value for a given name in the given environment.t localt globalt __builtins__t builtinN( t f_globalst typet hasattrt getattrt Nonet __UNDEF__( t namet framet localst builtins( ( s /usr/lib/python2.7/cgitb.pyt lookupA s c C s2 g d d d t f \ } } } } } xt j | ƒ D]ö \ } } } } } | t j k r\ Pn | t j k rõ | t j k rõ | d k rÄ | t k rò t | | t ƒ } | j | | | | f ƒ qò q$t | | | ƒ \ } } | j | | | f ƒ n/ | d k r| | d 7} | } n d \ } } | } q4 W| S( sE Scan one logical line of Python and look up values of variables used.R t .N( NR ( R R t tokenizet generate_tokenst NEWLINEt NAMEt keywordt kwlistR t appendR ( t readerR R t varst lasttokent parentt prefixt valuet ttypet tokent startt endt linet where( ( s /usr/lib/python2.7/cgitb.pyt scanvarsQ s" $% i c " sÔ | \ } } } t | ƒ t j k r0 | j } n d t j j ƒ d d t j } t j t j ƒ ƒ } d t j j d t t j j t | ƒ ƒ ƒ d d | d | ƒ d } d t d d ƒ d } g } t j | | ƒ } xø| D]ð\ } ‰ } } } } ˆ r4t j j ˆ ƒ ‰ d ˆ t j j ˆ ƒ f } n d ‰ } t j | ƒ \ } } } } d } | d k rd t | ƒ t j | | | | d d „ ƒ} n i ‰ | g ‡ ‡ f d † } t | | | ƒ } d d | | f g } | d+ k r´| | } x¸ | D] } t d d t t | ƒ ƒ t | ƒ ƒ d } | ˆ k rpd | t j j | ƒ f } | j d | ƒ n3 d | t j j | ƒ f } | j d t | ƒ ƒ | d 7} q Wn i g } } xÑ | D]É \ } } } | | k réqÈn d | | <| t k r€| d, k r"d | t | ƒ } n8 | d k r=t | ƒ } n | t | j d ƒ d! ƒ } | j d" | t j j | ƒ f ƒ qÈ| j | d# ƒ qÈW| j d t t d$ j | ƒ ƒ ƒ ƒ | j d% d&