ó
`¾Tc           @   s'  d  Z  d d l Z d d l Z d d l Z d d l m Z y d d l m Z Wn e k
 rg d Z n Xd d l
 m Z d d l m Z m Z m Z m Z m Z e ƒ  Z e j d ƒ Z e e ƒ Z d Z d	 Z d
 „  Z e d „ Z d e f d „  ƒ  YZ e ƒ  Z d „  Z d e f d „  ƒ  YZ d S(   s½  
    werkzeug.debug.repr
    ~~~~~~~~~~~~~~~~~~~

    This module implements object representations for debugging purposes.
    Unlike the default repr these reprs expose a lot more information and
    produce HTML instead of ASCII.

    Together with the CSS and JavaScript files of the debugger this gives
    a colorful and more compact output.

    :copyright: (c) 2014 by the Werkzeug Team, see AUTHORS for more details.
    :license: BSD.
iÿÿÿÿN(   t   format_exception_only(   t   deque(   t   escape(   t	   iteritemst   PY2t	   text_typet   integer_typest   string_typess   (?:\r\n|\r|\n){2,}sL   <div class=box>
  <h3>%(title)s</h3>
  <pre class=help>%(text)s</pre>
</div>sQ   <div class=box>
  <h3>%(title)s</h3>
  %(repr)s
  <table>%(items)s</table>
</div>c         C   s   t  ƒ  j |  ƒ S(   s9   Creates a debug repr of an object as HTML unicode string.(   t   DebugReprGeneratort   repr(   t   obj(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt
   debug_repr1   s    c         C   sV   t  ƒ  } |  t k r3 | j t j d ƒ j ƒ } n | j |  ƒ } t j j | ƒ d S(   sd   Print the object details to stdout._write (for the interactive
    console of the web debugger.
    i   N(	   R   t   missingt   dump_localst   syst	   _getframet   f_localst   dump_objectt   stdoutt   _write(   R
   t   gent   rv(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   dump6   s
    	t   _Helperc           B   s#   e  Z d  Z d „  Z d d „ Z RS(   s   Displays an HTML version of the normal help, for the interactive
    debugger only because it requires a patched sys.stdout.
    c         C   s   d S(   Ns(   Type help(object) for help about object.(    (   t   self(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   __repr__G   s    c         C   sí   | d  k r* t j j d t |  ƒ ƒ d  Sd d  l } | j | ƒ t j j ƒ  } t | t	 ƒ rv | j
 d d ƒ } n  t j | ƒ } t | ƒ d k r· | d } d j | d ƒ } n d } | d } t j j t i | d	 6| d
 6ƒ d  S(   Ns   <span class=help>%s</span>iÿÿÿÿs   utf-8t   ignorei   i    s   

t   Helpt   titlet   text(   t   NoneR   R   R   R	   t   pydoct   helpt   resett
   isinstancet   bytest   decodet   _paragraph_ret   splitt   lent   joint	   HELP_HTML(   R   t   topicR   R   t
   paragraphsR   R   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   __call__J   s    

N(   t   __name__t
   __module__t   __doc__R   R   R,   (    (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyR   B   s   	c         C   s‘   t  | t ƒ r9 x= | D] } t | ƒ | k r |  Sq Wn t | ƒ | k rO |  Sd } | j j d k rz d | j j } n  d | | j j |  f S(   Nt    t   __builtin__t
   exceptionss   <span class="module">%s.</span>s   %s%s(%s)(   s   __builtin__s
   exceptions(   R"   t   tuplet   typet	   __class__R.   R-   (   t   innerR
   t   baset   module(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   _add_subclass_info`   s    R   c           B   sò   e  Z d  „  Z e ƒ  d d „ Z e d d e ƒ Z e d d e ƒ Z e d d e	 ƒ Z
 e d	 d e ƒ Z e d k	 rŠ e d
 d e ƒ Z n  [ d „  Z d d „ Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d d „ Z RS(   c         C   s   g  |  _  d  S(   N(   t   _stack(   R   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   __init__o   s    i   c            s   ‡  ‡ ‡ ‡ f d †  } | S(   Nc            sÔ   | r t  ˆ d ˆ  | ˆ ƒ Sˆ g } t } xh t | ƒ D]Z \ } } | r\ | j d ƒ n  | ˆ k r~ | j d ƒ t } n  | j |  j | ƒ ƒ q: W| r® | j d ƒ n  | j ˆ  ƒ t  d j | ƒ | ˆ ƒ S(   Ns   ...s   , s   <span class="extended">s   </span>u    (   R9   t   Falset	   enumeratet   appendt   TrueR	   R(   (   R   R
   t	   recursivet   buft   have_extended_sectiont   idxt   item(   t   rightR7   t   limitt   left(    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   proxys   s    		(    (   RG   RE   R7   RF   RH   (    (   RE   RF   R7   RG   sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   _sequence_repr_makerr   s    t   [t   ]t   (t   )s   set([s   ])s   frozenset([s/   <span class="module">collections.</span>deque([c         C   sr   t  | j ƒ } t r* | j d d ƒ } n t j | d d ƒ } | d  d k r` d | d } n
 d | } d | S(	   Ns   string-escapeR   s   unicode-escapei   t   ut   urt   ru0   re.compile(<span class="string regex">%s</span>)(   R	   t   patternR   R$   t   codecs(   R   R
   RQ   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt
   regex_reprŽ   s    
iF   c         C   s×   d g } t  | ƒ } t | |  ƒ } t | | ƒ } t | t ƒ rn t rn | j d ƒ | d } | d } n  | d k rž | j | d  d | d d f ƒ n | j | ƒ | j d ƒ t d j | ƒ | t	 t f ƒ S(	   Ns   <span class="string">RN   i   s   ''iÿÿÿÿs   <span class="extended">s   </span>u    (
   R   R	   R"   R   R   R>   t   extendR9   R(   R#   (   R   R
   RF   RA   t   escapedt   at   b(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   string_reprš   s    	
$i   c   	      C   sï   | r t  d | t ƒ Sd g } t } x‹ t t | ƒ ƒ D]w \ } \ } } | r` | j d ƒ n  | | d k r† | j d ƒ t } n  | j d |  j | ƒ |  j | ƒ f ƒ q8 W| rÉ | j d ƒ n  | j d ƒ t  d	 j | ƒ | t ƒ S(
   Nu   {...}t   {s   , i   s   <span class="extended">sT   <span class="pair"><span class="key">%s</span>: <span class="value">%s</span></span>s   </span>t   }u    (	   R9   t   dictR<   R=   R   R>   R?   R	   R(   (	   R   t   dR@   RF   RA   RB   RC   t   keyt   value(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt	   dict_reprª   s     	%		$c         C   s5   t  | ƒ } t r' | j d d ƒ } n  d t | ƒ S(   Ns   utf-8t   replaceu   <span class="object">%s</span>(   R	   R   R$   R   (   R   R
   RP   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   object_repr½   s    c         C   s?  | t  k r d t  St | t t t f ƒ r4 d | St | t ƒ rP |  j | ƒ St | t ƒ rl |  j | ƒ St | t	 ƒ r‹ |  j
 | | ƒ St | t ƒ rª |  j | | ƒ St | t ƒ rÉ |  j | | ƒ St | t ƒ rè |  j | | ƒ St | t ƒ r|  j | | ƒ St d  k	 r2t | t ƒ r2|  j | | ƒ S|  j | ƒ S(   Nu   <span class="help">%r</span>u   <span class="number">%r</span>(   t   helperR"   R   t   floatt   complexR   RX   t	   RegexTypeRS   t   listt	   list_reprR3   t
   tuple_reprt   sett   set_reprt	   frozensett   frozenset_reprR[   R_   R   R   t
   deque_reprRa   (   R   R
   R@   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   dispatch_reprÃ   s*    c         C   sl   y# d j  t t j ƒ  d  Œ  ƒ } Wn t k
 r< d } n Xt rX | j d d ƒ } n  d t | j ƒ  ƒ S(   NR0   i   t   ?s   utf-8R   u8   <span class="brokenrepr">&lt;broken repr (%s)&gt;</span>(	   R(   R    R   t   exc_infot	   ExceptionR   R$   R   t   strip(   R   t   info(    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   fallback_reprÚ   s    #
c         C   sˆ   t  } x' |  j D] } | | k r t } Pq q W|  j j | ƒ z3 y |  j | | ƒ SWn t k
 rq |  j ƒ  SXWd  |  j j ƒ  Xd  S(   N(   R<   R:   R?   R>   Rn   Rq   Rt   t   pop(   R   R
   R@   RD   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyR	   ä   s    c         C   s)  d  } } t | t ƒ rz d } g  } xR t | ƒ D]A \ } } t | t ƒ sW d  } Pn  | j | |  j | ƒ f ƒ q2 Wn  | d  k rø g  } |  j | ƒ } xQ t | ƒ D]C } y) | j | |  j t | | ƒ ƒ f ƒ Wq¨ t	 k
 rê q¨ Xq¨ Wd } n  | d t
 j | ƒ d d !7} |  j | | | ƒ S(   Ns   Contents ofs   Details fort    i   iÿÿÿÿ(   R   R"   R[   R   R   R>   R	   t   dirt   getattrRq   t   objectR   t   render_object_dump(   R   R
   R	   t   itemsR   R]   R^   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyR   ó   s(    
#)	c         C   sD   g  | j  ƒ  D]! \ } } | |  j | ƒ f ^ q } |  j | d ƒ S(   Ns   Local variables in frame(   R{   R	   Rz   (   R   R\   R]   R^   R{   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyR   	  s    4c         C   sŒ   g  } x1 | D]) \ } } | j  d t | ƒ | f ƒ q W| sP | j  d ƒ n  t i t | ƒ d 6| rs d | pv d d 6d j | ƒ d 6S(	   Ns&   <tr><th>%s<td><pre class=repr>%s</pre>s   <tr><td><em>Nothing</em>R   s   <pre class=repr>%s</pre>R0   R	   s   
R{   (   R>   R   t   OBJECT_DUMP_HTMLR(   (   R   R{   R   R	   t
   html_itemsR]   R^   (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyRz     s    	N(   R-   R.   R;   Ry   RI   Rf   Rg   R3   Rh   Ri   Rj   Rk   Rl   R   R   Rm   RS   RX   R_   Ra   Rn   Rt   R	   R   R   Rz   (    (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyR   m   s(   					
			(    R/   R   t   reRR   t	   tracebackR    t   collectionsR   t   ImportErrorR   t   werkzeug.utilsR   t   werkzeug._compatR   R   R   R   R   Ry   R   t   compileR%   R4   Re   R)   R|   R   R   R   Rb   R9   R   (    (    (    sY   /var/www/send.findwatt.com/datamanager/lib/python2.7/site-packages/werkzeug/debug/repr.pyt   <module>   s*   
(				