-í
æ¶<c       s˜   d  Z  d Z d Z d k Z d „  Z g  Z d „  Z d „  Z d „  Z d „  Z	 d	 „  Z
 d
 d „ Z d f  d „  ƒ  YZ e ƒ  i Z d e d
 d „ Z d S(   s×  Handle exceptions in CGI scripts by formatting tracebacks into nice HTML.

To enable this module, do:

    import cgitb; cgitb.enable()

at the top of your CGI 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

By default, tracebacks are displayed but not saved, and context is 5.

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().s   Ka-Ping Yees   $Revision: 1.4 $Nc      s   d Sd S(   sA   Return a string that resets the CGI and browser to a known state.s'  <!--: spam
Content-Type: text/html

<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> -->
<body bgcolor="#f0f0f8"><font color="#f0f0f8" size="-5"> --> -->
</font> </font> </font> </script> </object> </blockquote> </pre>
</table> </table> </table> </table> </table> </font> </font> </font>N(    (    (    (    s   /usr/lib/python2.2/cgitb.pys   reset s     c    s   d |  d Sd  S(   Ns   <small>s   </small>(   s   text(   s   text(    (    s   /usr/lib/python2.2/cgitb.pys   small# s    c    s   d |  d Sd  S(   Ns   <strong>s	   </strong>(   s   text(   s   text(    (    s   /usr/lib/python2.2/cgitb.pys   strong$ s    c    s   d |  d Sd  S(   Ns   <font color="#909090">s   </font>(   s   text(   s   text(    (    s   /usr/lib/python2.2/cgitb.pys   grey% s    c    sR   |  | j o d | |  f Sn |  | i j o d | i |  f Sn t t f Sd S(   s9   Find the value for a given name in the given environment.s   locals   globalN(   s   names   localss   frames	   f_globalss   Nones	   __UNDEF__(   s   names   frames   locals(    (    s   /usr/lib/python2.2/cgitb.pys   lookup' s     c    sS  d k  } d k } g  t t d f \ } } } }
 x| i |  ƒ D]\ } } }	 } } | | i j o Pn | | i j o | | i j o€ | d j oA | t j	 o0 t | | t ƒ } | i |
 | |
 | f ƒ n n/ t | | | ƒ \ } } | i | | | f ƒ n8 | d j o |
 | d 7}
 | } n t d f \ } }
 | } q@ W| Sd S(   sE   Scan one logical line of Python and look up values of variables used.Ns    s   .(   s   tokenizes   keywords   Nones   varss	   lasttokens   parents   prefixs   generate_tokenss   readers   ttypes   tokens   starts   ends   lines   NEWLINEs   NAMEs   kwlists	   __UNDEF__s   getattrs   values   appends   lookups   frames   localss   where(   s   readers   frames   localss   ends   keywords   parents   varss   tokens   values   starts   prefixs   tokenizes   ttypes   lines   wheres	   lasttoken(    (    s   /usr/lib/python2.2/cgitb.pys   scanvars/ s(        "

i   c +   sÏ  |  \ } } } d k }* d k } d k }( d k }$ d k ‰ d k } d k	 ‰ t
 | ƒ | i j o | i } n d t i i ƒ  d d t i } |( i |( i ƒ  ƒ } d ˆ i i d t | ƒ d d | d	 | ƒ d
 } d t d d ƒ d }! g  } | i | | ƒ } xé| D]á\ } ‰  } } }% } ˆ  o |* i$ i% ˆ  ƒ p d ‰  d ˆ  ˆ i i& ˆ  ƒ f } | i( | ƒ \ } } } } d } | d j o6 d t. | ƒ | i/ | | | | d ‡ d †  ƒ} n h  ‰ | g ‡ ‡  ‡ d † } t2 | | | ƒ } d d | | f g } | t5 j	 o¬ | | }# x› |% D]“ } t d d t8 t |# ƒ ƒ t |# ƒ ƒ d } d | ˆ i i: | ƒ f } |# ˆ j o | i; d | ƒ n | i; d t< | ƒ ƒ |# d 7}# q0Wn h  g  f \ }	 } xÕ | D]Í \ }" } }
 |" |	 j o qän d |	 |" <|
 tB j	 o‚ | d j o d t. |" ƒ }" n; | d j o t. |" ƒ }" n | t. |" i d ƒ d  ƒ }" | i; d! |" ˆ i iC |
 ƒ f ƒ n | i; |" d" ƒ qäW| i; d t t< d# iD | ƒ ƒ ƒ ƒ | i; d$ d% iD | ƒ ƒ qWd& t. t | ƒ ƒ t | ƒ f g }  t
 | ƒ | iF j oP xI tG | ƒ D]; }" ˆ i iC tH | |" ƒ ƒ }
 |  i; d' |! |" |
 f ƒ qAWn d k }$ | d iD | ƒ d iD |  ƒ d( d iD |$ iI | | | ƒ ƒ Sd S()   s9   Return a nice HTML document describing a given traceback.Ns   Python i    s   : s   <body bgcolor="#f0f0f8">s)   <big><big><strong>%s</strong></big></big>s   #ffffffs   #6622aas   <br>s‡   
<p>A problem occurred in a Python script.  Here is the sequence of
function calls leading up to the error, in the order they occurred.s   <tt>s   &nbsp;i   s   &nbsp;</tt>s   ?s   <a href="file://%s">%s</a>s    s   in s   formatvaluec    s   d ˆ  i i |  ƒ S(   Ns   =(   s   pydocs   htmls   reprs   value(   s   value(   s   pydoc(    s   /usr/lib/python2.2/cgitb.pys   <lambda>^ s    c    s>   d ˆ  |  d <z ˆ i ˆ |  d ƒ SWd  |  d c d 7<Xd  S(   Ni   i    (   s	   highlights   lnums	   linecaches   getlines   file(   s   lnum(   s	   highlights   files	   linecache(    s   /usr/lib/python2.2/cgitb.pys   readera s     s+   <tr><td bgcolor="#d8bbff">%s%s %s</td></tr>s   <big>&nbsp;</big>s   <tt>%s%s</tt>s&   <tr><td bgcolor="#ffccee">%s</td></tr>s   <tr><td>%s</td></tr>i   s   globals   <em>global</em> s   locals   .iÿÿÿÿs   %s&nbsp;= %ss    <em>undefined</em>s   , sI   <p>
<table width="100%%" cellspacing=0 cellpadding=0 border=0>
%s</table>s   
s	   <p>%s: %ss   
<br>%s%s&nbsp;=
%ssî   


<!-- The above is a description of an error in a Python program, formatted
     for a Web browser because the 'cgitb' module was enabled.  In case you
     are not reading this in a Web browser, here is the original traceback:

%s
-->
(J   s   etypes   evalues   etbs   oss   typess   times	   tracebacks	   linecaches   inspects   pydocs   types	   ClassTypes   __name__s   syss   versions   splits
   executables   pyvers   ctimes   dates   htmls   headings   strs   heads   smalls   indents   framess   getinnerframess   contexts   recordss   frames   files   lnums   funcs   liness   indexs   paths   abspaths   escapes   links   getargvaluess   argss   varargss   varkws   localss   calls   strongs   formatargvaluess	   highlights   readers   scanvarss   varss   rowss   Nones   is   lines   lens   nums	   preformats   appends   greys   dones   dumps   names   wheres   values	   __UNDEF__s   reprs   joins	   exceptions   InstanceTypes   dirs   getattrs   format_exception(+   s   .0s   contexts   etypes   evalues   etbs   varss   lnums   frames   nums   dones   values   files   framess   wheres   localss   indexs   rowss   dumps   pyvers   calls   readers   varkws   heads   inspects   argss   recordss   links   funcs   varargss   dates   lines   typess	   exceptions   indents   names   is	   tracebacks   liness   pydocs	   linecaches   times	   highlights   os(    (   s   files   pydocs	   linecaches	   highlights   /usr/lib/python2.2/cgitb.pys   htmlE st    ?"  
 .  
  '&% "	s   Hookc      s8   t  Z d  Z d e d e d „ Z d „  Z e d „ Z RS(   s?   A hook to replace sys.excepthook that shows tracebacks in HTML.i   i   c    s2   | |  _  | |  _ | |  _ | p t i |  _ d  S(   N(   s   displays   selfs   logdirs   contexts   files   syss   stdout(   s   selfs   displays   logdirs   contexts   file(    (    s   /usr/lib/python2.2/cgitb.pys   __init__š s    			c    s   |  i | | | f ƒ d  S(   N(   s   selfs   handles   etypes   evalues   etb(   s   selfs   etypes   evalues   etb(    (    s   /usr/lib/python2.2/cgitb.pys   __call__  s    c    sÐ  | p
 t i ƒ  } |  i i t ƒ  ƒ y" d t | |  i ƒ f \ } } Wn4 d  k } d d i | i | Œ  ƒ f \ } } n X|  i oY | o: | i d d ƒ i d d ƒ } |  i i d | d	 ƒ n |  i i | d
 ƒ n |  i i d ƒ |  i t j	 o¯ d  k }
 d  k } | i d d g | ƒ } |
 i i |  i |
 i i | ƒ ƒ }	 y4 t |	 d ƒ } | i | ƒ | i ƒ  d |	 } Wn d |	 } n X|  i i | d
 ƒ n y |  i i ƒ  Wn n Xd  S(   Ni    i   s    s   &s   &amp;s   <s   &lt;s   <pre>s   </pre>
s   
s*   <p>A problem occurred in a Python script.
s   .htmls   .txts   ws.   <p> %s contains the description of this error.s.   <p> Tried to save traceback to %s, but failed.(   s   infos   syss   exc_infos   selfs   files   writes   resets   htmls   contexts   texts   docs	   tracebacks   joins   format_exceptions   displays   replaces   logdirs   Nones   oss   tempfiles   mktemps   names   paths   basenames   opens   closes   msgs   flush(   s   selfs   infos   names   tempfiles   texts	   tracebacks   files   docs   msgs   paths   os(    (    s   /usr/lib/python2.2/cgitb.pys   handle£ s:    "	(
$
 (   s   __name__s
   __module__s   __doc__s   Nones   __init__s   __call__s   handle(    (    (    s   /usr/lib/python2.2/cgitb.pys   Hook— s    	i   c    s   t  |  | | ƒ t _ d S(   s  Install an exception handler that formats tracebacks as HTML.

    The optional argument 'display' can be set to 0 to suppress sending the
    traceback to the browser, and 'logdir' can be set to a directory to cause
    tracebacks to be written to files there.N(   s   Hooks   displays   logdirs   contexts   syss
   excepthook(   s   displays   logdirs   context(    (    s   /usr/lib/python2.2/cgitb.pys   enableÇ s     (   s   __doc__s
   __author__s   __version__s   syss   resets	   __UNDEF__s   smalls   strongs   greys   lookups   scanvarss   htmls   Hooks   handles   handlers   Nones   enable(   s   resets   __version__s   handlers   scanvarss   enables   greys
   __author__s   syss   Hooks   htmls   lookups   smalls   strongs	   __UNDEF__(    (    s   /usr/lib/python2.2/cgitb.pys   ? s   		
					R/