
     fW$                       d Z ddlmZ ddlZddlZddlZddlZddlm	Z	 ddl
mZ ddlmZ  e            Z ej        d          Z ee          ZdZd	Zd!dZefd"dZ G d d          Z e            Zd#dZ	 d$d%dZ G d d           ZdS )&zObject representations for debugging purposes. Unlike the default
repr, these expose more information and produce HTML instead of ASCII.

Together with the CSS and JavaScript of the debugger this gives a
colorful and more compact output.
    )annotationsN)deque)format_exception_only)escapez(?:\r\n|\r|\n){2,}zL<div class=box>
  <h3>%(title)s</h3>
  <pre class=help>%(text)s</pre>
</div>zQ<div class=box>
  <h3>%(title)s</h3>
  %(repr)s
  <table>%(items)s</table>
</div>objobjectreturnstrc                D    t                                          |           S )z1Creates a debug repr of an object as HTML string.)DebugReprGeneratorrepr)r   s    V/var/www/api.educacionweb.es/myenv/lib/python3.11/site-packages/werkzeug/debug/repr.py
debug_reprr   &   s    $$S)))    Nonec                    t                      }| t          u r-|                    t          j        d          j                  }n|                    |           }t          j                            |           dS )zdPrint the object details to stdout._write (for the interactive
    console of the web debugger.
       N)	r   missingdump_localssys	_getframef_localsdump_objectstdout_write)r   genrvs      r   dumpr   +   se     

C
g~~__S]1--677__S!!Jbr   c                  $    e Zd ZdZd
dZddd	ZdS )_HelperzDisplays an HTML version of the normal help, for the interactive
    debugger only because it requires a patched sys.stdout.
    r	   r
   c                    dS )Nz(Type help(object) for help about object. selfs    r   __repr__z_Helper.__repr__<   s    99r   Ntopict.Any | Noner   c                   |%t           j                            d| d           d S dd l}|                    |           t           j                                        }t                              |          }t          |          dk    r&|d         }d	                    |dd                    }n
d}|d         }t           j                            t          ||dz             d S )Nz<span class=help></span>r   r   z

Help)titletext)r   r   r   pydochelpreset_paragraph_resplitlenjoin	HELP_HTML)r$   r&   r-   r   
paragraphsr+   r,   s          r   __call__z_Helper.__call__?   s    =JA$AAABBBF

5Z"((,,
z??QqME;;z!""~..DDEa=D
)t&D&DDEEEEEr   r	   r
   N)r&   r'   r	   r   )__name__
__module____qualname____doc__r%   r6   r"   r   r   r    r    7   sR         : : : :F F F F F F Fr   r    innerbasetype | tuple[type, ...]c                    t          |t                    r|D ]}t          |          |u r| c S nt          |          |u r| S d}|j        j        dvrd|j        j         d}| t          |          j         d|  dS )N )__builtin__
exceptionsz<span class="module">z.</span>())
isinstancetupletype	__class__r:   r9   )r=   r   r>   clsmodules        r   _add_subclass_inforL   T   s    $  	 	CCyyC  	 
cd		F
}'DDDK)AKKK3d3ii(3353333r      leftrightrH   limitint>t.Callable[[DebugReprGenerator, t.Iterable[t.Any], bool], str]c                      d
 fd	}|S )Nr$   r   r   t.Iterable[t.Any]	recursiveboolr	   r
   c                   |rt           d
 |          S g}d}t          |          D ]a\  }}|r|                    d           |	k    r|                    d           d}|                    |                     |                     b|r|                    d           |                    
           t          d                    |          |          S )Nz...F, <span class="extended">Tr)   rA   )rL   	enumerateappendr   r3   )r$   r   rU   bufhave_extended_sectionidxitemr>   rN   rP   rO   s          r   proxyz#_sequence_repr_maker.<locals>.proxyd   s     	F%&9&9%&9&93EEEf %"3 	( 	(IC !

4   e||

4555(,%JJtyy''''  	"JJy!!!

5!"''#,,T:::r   )r$   r   r   rT   rU   rV   r	   r
   r"   )rN   rO   r>   rP   r`   s   ```` r   _sequence_repr_makerra   a   s:    ; ; ; ; ; ; ; ; ;" Lr   c                      e Zd Z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d	e          Zd,dZd-d.dZ	 d/d0dZd1dZd2dZd3dZd4d Zd4d!Zd5d#Z	 d6d7d*Zd$S )8r   r	   r   c                    g | _         d S r8   )_stackr#   s    r   __init__zDebugReprGenerator.__init__y   s    #%r   []rD   rE   zset([z])zfrozenset([z/<span class="module">collections.</span>deque([r   t.Pattern[t.AnyStr]r
   c                l    t          |j                  }t          j        |dd          }d| }d| dS )Nzunicode-escapeignorerz&re.compile(<span class="string regex">z</span>))r   patterncodecsdecode)r$   r   rl   s      r   
regex_reprzDebugReprGenerator.regex_repr   sA    s{##-)98DDg--IIIIIr   F   str | bytesrP   rQ   c           	        dg}t          |          }t          |          |z
  dk    rD|                    t          |d |                   dt          ||d                    df           n"|                    t          |                     |                    d           d                    |          }|d         dv s|d         dk    r'|d	         dv rt          ||t          t          f          S |S )
Nz<span class="string">   rY   r)   rA   r   z'"br   )	r   r2   extendr   r[   r3   rL   bytesr
   )r$   r   rP   r\   rk   outs         r   string_reprzDebugReprGenerator.string_repr   s    &'II q66E>AJJ1VeV9%%-1UVV9%%	    JJvayy!!!

9ggcll Q45==QqTS[[QqTU]]%c3=== 
r      d7dict[int, None] | dict[str, int] | dict[str | int, int]rU   rV   c           	     ,   |rt          d|t                    S dg}d}t          |                                          D ]\  }\  }}|r|                    d           ||dz
  k    r|                    d           d}|                    d|                     |           d	|                     |           d
           |r|                    d           |                    d           t          d                    |          |t                    S )Nz{...}{FrX   r   rY   Tz%<span class="pair"><span class="key">z</span>: <span class="value">z</span></span>r)   }rA   )rL   dictrZ   itemsr[   r   r3   )	r$   rz   rU   rP   r\   r]   r^   keyvalues	            r   	dict_reprzDebugReprGenerator.dict_repr   s6     	8%gq$777e %!*17799!5!5 		 		C#u !

4   eai

4555(,%JJI		# I I(,		%(8(8I I I    ! 	"JJy!!!

3!"''#,,4888r   t.Anyc                F    t          |          }dt          |           dS )Nz<span class="object">r)   )r   r   )r$   r   rk   s      r   object_reprzDebugReprGenerator.object_repr   s$    II9vayy9999r   c                z   |t           u rdt           dS t          |t          t          t          f          rd|dS t          |t
                    st          |t                    r|                     |          S t          |t                    r| 	                    |          S t          |t                    r|                     ||          S t          |t                    r|                     ||          S t          |t                    r|                     ||          S t          |t                     r|                     ||          S t          |t$                    r|                     ||          S t          |t(                    r|                     ||          S |                     |          S )Nz<span class="help">r)   z<span class="number">)helperrF   rQ   floatcomplexr
   rv   rx   	RegexTypero   list	list_reprrG   
tuple_reprsetset_repr	frozensetfrozenset_reprr   r   r   
deque_reprr   )r$   r   rU   s      r   dispatch_reprz DebugReprGenerator.dispatch_repr   s   &==:::::cC011 	:939999c3 	):c5#9#9 	)##C(((c9%% 	(??3'''c4   	2>>#y111c5!! 	3??3	222c3 	1==i000c9%% 	7&&sI666c4   	2>>#y111c5!! 	3??3	222$$$r   c                    	 d                     t          t          j                    d d                    }n# t          $ r d}Y nw xY wdt          |                                           dS )NrA   rs   ?z*<span class="brokenrepr">&lt;broken repr (z)&gt;</span>)r3   r   r   exc_info	Exceptionr   strip)r$   infos     r   fallback_reprz DebugReprGenerator.fallback_repr   s    	770#,..!2DEFFDD 	 	 	DDD	C &tzz|| 4 4C C C	
s   58 AAr   c                v   d}| j         D ]
}||u rd} n| j                             |           	 	 |                     ||          | j                                          S # t          $ r0 |                                 cY | j                                          S w xY w# | j                                          w xY w)NFT)rd   r[   r   popr   r   )r$   r   rU   r_   s       r   r   zDebugReprGenerator.repr   s    	K 	 	Ds{{ 	  	3	,))#y99 KOO  , , ,))++++KOO, KOOs#   A   B>B BB B8c           
     `   d }d }t          |t                    rad}g }|                                D ]H\  }}t          |t                    sd } n+|                    ||                     |          f           I|tg }|                     |          }t          |          D ]K}	 |                    ||                     t          ||                    f           <# t          $ r Y Hw xY wd}|dt          
                    |          dd          z  }|                     |||          S )NzContents ofzDetails for r   )rF   r   r   r
   r[   r   dirgetattrr   r   r%   render_object_dump)r$   r   r   r   r+   r   r   s          r   r   zDebugReprGenerator.dump_object   sM   .2c4   	6!EE!iikk 6 6
U!#s++  EEc499U#3#345555=E99S>>D3xx  LL#tyyc1B1B'C'C!DEEEE    D!E1V__S))!B$/111&&ueT:::s   &8C
C,+C,dict[str, t.Any]c                p      fd|                                 D             }                     |d          S )Nc                D    g | ]\  }}|                     |          fS r"   )r   ).0r   r   r$   s      r   
<listcomp>z2DebugReprGenerator.dump_locals.<locals>.<listcomp>  s.    EEEZS%#tyy''(EEEr   zLocal variables in frame)r   r   )r$   rz   r   s   `  r   r   zDebugReprGenerator.dump_locals
  s;    EEEE17799EEE&&u.HIIIr   Nr   list[tuple[str, str]]r+   r   
str | Nonec                   g }|D ].\  }}|                     dt          |           d| d           /|s|                     d           t          t          |          d|r|nd dd                    |          dz  S )	Nz<tr><th>z<td><pre class=repr>z</pre>z<tr><td><em>Nothing</em>z<pre class=repr>rA   
)r+   r   r   )r[   r   OBJECT_DUMP_HTMLr3   )r$   r   r+   r   
html_itemsr   r   s          r   r   z%DebugReprGenerator.render_object_dump  s     
 	Y 	YJCWWW%WWWXXXX 	:8999E]]Ct';ttCCCYYz**#
 #
 
 	
r   )r	   r   )r   rh   r	   r
   )rp   )r   rq   rP   rQ   r	   r
   )ry   )rz   r{   rU   rV   rP   rQ   r	   r
   )r   r   r	   r
   )r   r   rU   rV   r	   r
   r7   r   r   r	   r
   )rz   r   r	   r
   r8   )r   r   r+   r
   r   r   r	   r
   )r9   r:   r;   re   ra   r   r   rG   r   r   r   r   r   r   r   ro   rx   r   r   r   r   r   r   r   r   r"   r   r   r   r   x   s~       & & & & %$S#t44I%%c366J##GT377H))-yIIN%%94 JJ J J J    > 	9 9 9 9 92: : : :% % % %.
 
 
 
   ; ; ; ;0J J J J
 LP
 
 
 
 
 
 
r   r   r   )r   r   r	   r   )r=   r
   r   r   r>   r?   r	   r
   )rM   )
rN   r
   rO   r
   r>   rH   rP   rQ   r	   rR   )r<   
__future__r   rm   rer   typingtcollectionsr   	tracebackr   
markupsafer   r   r   compiler0   rH   r   r4   r   r   r   r    r   rL   ra   r   r"   r   r   <module>r      s    # " " " " "  				 



           + + + + + +      
&((
011D		 * * * *
  	 	 	 	 	F F F F F F F F4 

4 
4 
4 
4 56    .b
 b
 b
 b
 b
 b
 b
 b
 b
 b
r   