o
    1c<                     @   s  U 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mZ d dlmZm	Z	m
Z
mZmZ d dlmZmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZmZmZmZmZmZmZmZmZm Z  d d	l!m"Z" zd dl#Z$W n e%yz   dZ$Y nw d
dl&m'Z' d
dl(m)Z) d
dl*m+Z+ d
dl,m-Z- d
dl.m/Z/ d
dl0m1Z1 d
dl2m3Z3m4Z4 d
dl5m6Z6 d
dl7m8Z8 erd
dl9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z? dede@fddZAdeded fddZBdeCde@fddZD							djd ed!ed" d#d$d%e@d&e@d'eeE d(eeE d)e@ddfd*d+ZF							djd!ed" d#d$d%e@d&e@d'eeE d(eeE d)e@ddfd,d-ZGG d.d/ d/e3ZHd0eeef deeIeIeIf fd1d2ZJd0d3deeIeIeIf fd4d5ZKejLd6d7 eeKeeJed8d7 ed9d7 eMd:d7 e	d;d7 eNd<d7 eOd=d7 e
d>d7 ePd?d7 eQd@d7 edAd7 iZReeSeegeeIeIeIf f f eTdB< eQeRU ZVeMejLee	fZWdede@fdCdDZXeG dEdF dFZYeG dGdH dHZZ			dkd0ed'eeE d(eeE dIeeE deYf
dJdKZ[dLdMdddddNd0edOeEdPeEd'eeE d(eeE dIeeE d)e@deIfdQdRZ\ddSdddddTd0ed!ed" d&e@d'eeE d(eeE dIeeE d)e@ddfdUdVZ]e^dWkrmG dXdY dYZ_eeEZ`dZe`d[< d
d\d]d^d_h d`geNh daeeOdbg dcieg dddee_ dfZaead[ bea d dglcmdZd edeHeadSdhdi dS dS )l    N)array)CounterUserDictUserListdefaultdictdeque)	dataclassfieldsis_dataclass)isclass)islice)MappingProxyType)TYPE_CHECKINGAnyCallableDefaultDictDictIterableListOptionalSetTupleUnion)RichReprResult   get_console)	loop_last)	pick_bool)RichRenderablecell_len)ReprHighlighter)JupyterMixinJupyterRenderable)Measurement)Text)ConsoleConsoleOptionsHighlighterTypeJustifyMethodOverflowMethodRenderResultobjreturnc                 C   s   t duo
t t| S )z1Check if an object was created with attrs module.N)_attr_moduleZhastyper-    r2   P/var/www/html/django/env/lib/python3.10/site-packages/pip/_vendor/rich/pretty.py_is_attr_object8   s   r4   z_attr_module.Attribute[Any]c                 C   s   t durt t| S g S )zGet fields for an attrs object.N)r/   r	   r0   r1   r2   r2   r3   _get_attr_fields=   s   r5   c                 C   s(   z	| j jjtjkW S  ty   Y dS w )zCheck if an instance of a dataclass contains the default repr.

    Args:
        obj (object): A dataclass instance.

    Returns:
        bool: True if the default repr is used, False if there is a custom repr.
    F)__repr____code__co_filenamedataclasses__file__	Exceptionr1   r2   r2   r3   _is_dataclass_reprB   s
   r<   ignoreFvalueconsoler'   overflowr+   cropindent_guides
max_length
max_string
expand_allc              
   C   s   ddl m} t| ts| d u rd S |pt }|jrCg d}	|	D ]#}
t| |
d }t|rBz| }W n	 t	y:   Y qw |d urB d S qt| |rL|
  |jt| trU| n
t| |||||dd|dd d S )Nr   )ConsoleRenderable)Z_repr_html_Z_repr_markdown_Z_repr_json_Z_repr_latex_Z_repr_jpeg_Z
_repr_png_Z
_repr_svg__repr_mimebundle_   )r@   rB   rC   rD   rE   marginT)rA   new_line_start)r?   rF   
isinstancer$   r   
is_jupytergetattrinspectismethodr;   lineprintr   Pretty)r>   r?   r@   rA   rB   rC   rD   rE   rF   Zipython_repr_methodsZrepr_methodmethodZrepr_resultr2   r2   r3   _ipy_display_hookS   sD   





	
rT   c                    s   ddl m  p
   dusJ dtddf fdd}z$t }ddlm}	 G fd	d
d
|	}
|
 }||jjd< W dS  tyS   |t	_
Y dS w )a  Install automatic pretty printing in the Python REPL.

    Args:
        console (Console, optional): Console instance or ``None`` to use global console. Defaults to None.
        overflow (Optional[OverflowMethod], optional): Overflow method. Defaults to "ignore".
        crop (Optional[bool], optional): Enable cropping of long lines. Defaults to False.
        indent_guides (bool, optional): Enable indentation guides. Defaults to False.
        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to None.
        max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
        expand_all (bool, optional): Expand all containers. Defaults to False.
        max_frames (int): Maximum number of frames to show in a traceback, 0 for no maximum. Defaults to 100.
    r   r   Nr>   r.   c              	      sT   | dur( dus
J dt _ jt| tr| n	t| dd | t _dS dS )z?Replacement sys.displayhook which prettifies objects with Rich.N)r@   rB   rC   rD   rE   )rA   )builtins_rQ   rK   r   rR   )r>   )r?   rA   rE   rB   rC   rD   r@   r2   r3   display_hook   s$   
zinstall.<locals>.display_hook)BaseFormatterc                       s:   e Zd ZU dZeed< dedef fddZdS )zinstall.<locals>.RichFormatterTpprintr>   r.   c              	      s&   | j rt|  dS t|S )N)r?   r@   rB   rC   rD   rE   )rY   rT   repr)selfr>   rE   r   rB   rC   rD   r@   r2   r3   __call__   s   
z'install.<locals>.RichFormatter.__call__N)__name__
__module____qualname__rY   bool__annotations__r   r]   r2   r\   r2   r3   RichFormatter   s   
 $rc   z
text/plain)pip._vendor.richr   r   get_ipythonZIPython.core.formattersrX   Zdisplay_formatterZ
formattersr;   sysdisplayhook)r?   r@   rA   rB   rC   rD   rE   rW   iprX   rc   Zrich_formatterr2   )r?   rA   rE   r   rB   rC   rD   r@   r3   install   s   
"ri   c                   @   s   e Zd ZdZ	d$dddddddddddddeded	 d
eded ded dee dedee dee dee dedededdfddZ						d%dd Z							!d&d"d#Z
dS )'rR   ak  A rich renderable that pretty prints an object.

    Args:
        _object (Any): An object to pretty print.
        highlighter (HighlighterType, optional): Highlighter object to apply to result, or None for ReprHighlighter. Defaults to None.
        indent_size (int, optional): Number of spaces in indent. Defaults to 4.
        justify (JustifyMethod, optional): Justify method, or None for default. Defaults to None.
        overflow (OverflowMethod, optional): Overflow method, or None for default. Defaults to None.
        no_wrap (Optional[bool], optional): Disable word wrapping. Defaults to False.
        indent_guides (bool, optional): Enable indentation guides. Defaults to False.
        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to None.
        max_string (int, optional): Maximum length of string before truncating, or None to disable. Defaults to None.
        max_depth (int, optional): Maximum depth of nested data structures, or None for no maximum. Defaults to None.
        expand_all (bool, optional): Expand all containers. Defaults to False.
        margin (int, optional): Subtrace a margin from width to force containers to expand earlier. Defaults to 0.
        insert_line (bool, optional): Insert a new line if the output has multiple new lines. Defaults to False.
    N   Fr   )indent_sizejustifyr@   no_wraprB   rC   rD   	max_depthrE   rI   insert_line_objecthighlighterr)   rk   rl   r*   r@   r+   rm   rB   rC   rD   rn   rE   rI   ro   r.   c                C   sX   || _ |pt | _|| _|| _|| _|| _|| _|| _|	| _	|
| _
|| _|| _|| _d S N)rp   r"   rq   rk   rl   r@   rm   rB   rC   rD   rn   rE   rI   ro   )r[   rp   rq   rk   rl   r@   rm   rB   rC   rD   rn   rE   rI   ro   r2   r2   r3   __init__   s   
zPretty.__init__r?   r'   optionsr(   r,   c              	   c   s    t | j|j| j | j| j| j| j| jd}t	|| j
p|j
| jp"|jt| j|jdd}|r3| |nt	t| j ddd}| jrM|jsM|j| jdd}| jrWd|v rWd	V  |V  d S )
N	max_widthrk   rC   rD   rn   rE   pretty)rl   r@   rm   stylez.__repr__ returned empty stringz
dim italic)rx   zrepr.indent
 )pretty_reprrp   rv   rI   rk   rC   rD   rn   rE   r&   rl   r@   r   rm   rq   r0   rB   
ascii_onlywith_indent_guidesro   )r[   r?   rt   
pretty_strZpretty_textr2   r2   r3   __rich_console__  s>   
	

	
zPretty.__rich_console__r%   c                 C   sD   t | j|j| j| j| jd}|rtdd | D nd}t||S )N)rv   rk   rC   rD   c                 s       | ]}t |V  qd S rr   r    .0rP   r2   r2   r3   	<genexpr>?      z*Pretty.__rich_measure__.<locals>.<genexpr>r   )	r{   rp   rv   rk   rC   rD   max
splitlinesr%   )r[   r?   rt   r~   
text_widthr2   r2   r3   __rich_measure__4  s   
zPretty.__rich_measure__rr   )r?   r'   rt   r(   r.   r,   )r?   r'   rt   r(   r.   r%   )r^   r_   r`   __doc__r   r   intra   rs   r   r   r2   r2   r2   r3   rR      st    	


#rR   rp   c                 C   s   d| j ddd| j dfS )Nzdefaultdict(z, {})z, {}))default_factoryrp   r2   r2   r3   _get_braces_for_defaultdictD  s   r   z
array[Any]c                 C   s   d| j dddfS )Nzarray(z, [])zarray({_object.typecode!r}))typecoder   r2   r2   r3   _get_braces_for_arrayL  s   r   c                 C      dS )N)z	environ({r   zenviron({})r2   r   r2   r2   r3   <lambda>Q      r   c                 C   r   )N)z	Counter({r   z	Counter()r2   r   r2   r2   r3   r   T  r   c                 C   r   )N)zdeque([r   zdeque()r2   r   r2   r2   r3   r   U  r   c                 C   r   N){}z{}r2   r   r2   r2   r3   r   V  r   c                 C   r   r   r2   r   r2   r2   r3   r   W  r   c                 C   r   )N)zfrozenset({r   zfrozenset()r2   r   r2   r2   r3   r   X  r   c                 C   r   N)[]z[]r2   r   r2   r2   r3   r   Y  r   c                 C   r   r   r2   r   r2   r2   r3   r   Z  r   c                 C   r   )N)r   r   zset()r2   r   r2   r2   r3   r   [  r   c                 C   r   )N)()()r2   r   r2   r2   r3   r   \  r   c                 C   r   )N)zmappingproxy({r   zmappingproxy({})r2   r   r2   r2   r3   r   ]  r   _BRACESc                 C   s.   t | tpt| pt| dpt| ot|  S )z3Check if an object may be expanded by pretty print.__rich_repr__)rK   _CONTAINERSr
   hasattrr4   r   r1   r2   r2   r3   is_expandablec  s   
r   c                	   @   s   e Zd ZU dZdZeed< dZeed< dZeed< dZ	eed< dZ
eed< dZeed	< dZeed
< dZeed   ed< dZdZeed< dee fddZdededefddZdefddZ	d dedededefddZdS )!Nodez4A node in a repr tree. May be atomic or a container.rz   key_repr
value_repr
open_braceclose_braceemptyFlastis_tupleNchildrenz: z, 	separatorr.   c                 c   s    | j r| j V  | jV  | jr| jV  dS | jdurY| jrS| jV  | jr9t| jdkr9| jd  E dH  dV  n| jD ]}| E dH  |jsL| j	V  q<| j
V  dS | jV  dS dS )zGenerate tokens for this node.Nr   r   ,)r   key_separatorr   r   r   r   leniter_tokensr   r   r   r   )r[   childr2   r2   r3   r   |  s(   

zNode.iter_tokensstart_lengthrC   c                 C   s0   |}|   D ]}|t|7 }||kr dS qdS )a*  Check the length fits within a limit.

        Args:
            start_length (int): Starting length of the line (indent, prefix, suffix).
            max_length (int): Maximum length.

        Returns:
            bool: True if the node can be rendered within max length, otherwise False.
        FT)r   r!   )r[   r   rC   total_lengthtokenr2   r2   r3   check_length  s   
zNode.check_lengthc                 C   s   d |  }|S Nrz   )joinr   )r[   Z	repr_textr2   r2   r3   __str__  s   zNode.__str__P   rj   rv   rk   rE   c                 C   s   t | ddg}d}|t|k r5|| }|jr+|js+|s ||s+|||||d < |d7 }|t|k sddd |D }|S )al  Render the node to a pretty repr.

        Args:
            max_width (int, optional): Maximum width of the repr. Defaults to 80.
            indent_size (int, optional): Size of indents. Defaults to 4.
            expand_all (bool, optional): Expand all levels. Defaults to False.

        Returns:
            str: A repr string of the original object.
        T)nodeis_rootr   r   ry   c                 s   r   rr   )strr   r2   r2   r3   r     r   zNode.render.<locals>.<genexpr>)_Liner   
expandableexpandedr   expandr   )r[   rv   rk   rE   linesline_norP   repr_strr2   r2   r3   render  s   zNode.render)r   rj   F)r^   r_   r`   r   r   r   rb   r   r   r   r   r   ra   r   r   r   r   r   r   r   r   r   r   r   r   r2   r2   r2   r3   r   m  s2   
 r   c                   @   s   e Zd ZU dZdZed  ed< dZeed< dZ	ee
 ed< dZeed< dZeed	< dZeed
< dZeed< dZeed< edefddZdedefddZdeded  fddZdefddZdS )r   zA line in repr output.NparentFr   r   rz   textsuffix
whitespacer   r   r.   c                 C   s   t | jduo	| jjS )z"Check if the line may be expanded.N)ra   r   r   r[   r2   r2   r3   r     s   z_Line.expandablerC   c                 C   s:   t | jt| j t| j }| jdusJ | j||S )z4Check this line fits within a given number of cells.N)r   r   r!   r   r   r   r   )r[   rC   r   r2   r2   r3   r     s   z_Line.check_lengthrk   c                 c   s    | j }|dus
J | j}|jsJ |jr&t|j |j |j |dV }nt|j|dV }| jd|  }|jo>t|jdk}t	|jD ]\}}|rLdn|j
}	t||||	|oX| d}
|
V  qDt|j|| j| jdV  dS )z6Expand this line by adding children on their own line.N)r   r    r   r   )r   r   r   r   r   )r   r   r   r   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   )r[   rk   r   r   new_lineZchild_whitespaceZtuple_of_oner   r   r   rP   r2   r2   r3   r     s:   

z_Line.expandc                 C   sD   | j r| j | j | jpd S | j | j | jpd | j  S r   )r   r   r   r   r   rstripr   r2   r2   r3   r     s   "z_Line.__str__)r^   r_   r`   r   r   r   rb   r   ra   r   r   r   r   r   r   r   r   propertyr   r   r   r   r   r   r2   r2   r2   r3   r     s   
 !r   rn   c              	      sd   dt dtffddt jjddt dtdtdtf fd	d
  | dd}|S )a`  Traverse object and generate a tree.

    Args:
        _object (Any): Object to be traversed.
        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to None.
        max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
            Defaults to None.
        max_depth (int, optional): Maximum depth of data structures, or None for no maximum.
            Defaults to None.

    Returns:
        Node: The root of a tree structure which can be used to render a pretty repr.
    r-   r.   c              
      s    dur$t | ttfr$t|  kr$t|   }| d  d| }|S zt| }W |S  tyF } zdt|d}W Y d}~|S d}~ww )z0Get repr string for an object, but catch errors.N+z<repr-error >)rK   bytesr   r   rZ   r;   )r-   Z	truncatedobj_reprerror)rD   r2   r3   to_repr  s"   

ztraverse.<locals>.to_reprFr   rootdepthc           #   	      s  t }tjjtjjf}duo|k}dtdttttt	tf f  fdd}zt
d}W n ty9   d}Y nw d}|sWzt
drLtsL }W n	 tyV   Y nw |durtjd	d}	t||}
jj}|
rg }|j}|r|td
d}nT|	rtd| dd||dd}nt| dd||d}t|
D ]2\}}t|tr|\}}||d d}||_||_d|_|| q||d d}||_|| qn t|	rd| dn| dg |d}ntrg|sgg }|j}t  rY|rtd
d}ntjj dd||d}dttt	ttttgt	f  f  f fdd}t| D ]*\}\}}}|r@tt	||d}n||d d}||_||_d|_|| q,nwtjj dg |d}nitrtt s|sts|dkrt }|v rtd
dS | g }|j}|rtd
d}n0tjj dd||d}tdd t!D D ]\}}t|j"|d d}|j"|_||_d|_|| q| ntt#rt#D ]}t|r|} nqt }|v rtd
dS | t$| \}}}|rtd
|d}n|j%t j%kr*t|d}nrg }t||||d}|j}t&}|d }tt'r{t() } durXt*| } t+| D ]\}!\}}||d d}||_|!|k|_|| q\n)t(}"durt*|"}"t+|"D ]\}!}||d d}|!|k|_|| qdur|kr|td|  dd nt|g |d }| nt|d}tt|_,|S )!zWalk the object depth first.N	rich_argsr.   c                 s   s    | D ]<}t |tr<t|dkr |\}}}||krq||fV  qt|dkr0|\}}||fV  qt|dkr;|d V  q|V  qd S )N      r   r   )rK   tupler   )r   argkeyr   defaultr2   r2   r3   iter_rich_args6  s    


z3traverse.<locals>._traverse.<locals>.iter_rich_argsZ,awehoi234_wdfjwljet234_234wdfoijsdfmmnxpi492Fr   angularz...)r   <r   r   )r   r   r   r   r   r   r   )r   r   r   r   r   )r   =r   )r   r   r   c                  3   sx     D ]6} | j r9zt| j}W n ty) } z| j|dfV  W Y d}~qd}~ww | j|t| j r5| j ndfV  qdS )z$Iterate over attr fields and values.N)rZ   rM   namer;   callable)attrr>   r   Zattr_fieldsr-   r2   r3   
iter_attrs  s   z/traverse.<locals>._traverse.<locals>.iter_attrs)r      c                 s   s    | ]}|j r|V  qd S rr   )rZ   )r   fieldr2   r2   r3   r     s    
z.traverse.<locals>._traverse.<locals>.<genexpr>)r   r   z... +T)r   r   r   )-r0   rf   version_infomajorminorr   r   r   r   r   r   r;   r   r   rM   list	__class__r^   appendr   r   rK   r   r   r   r   r4   r5   r   r   r
   r<   idr	   r   r   r   r6   r   _MAPPING_CONTAINERSiteritemsr   	enumerater   )#r-   r   r   Zobj_type
py_versionZreached_max_depthr   Zfake_attributesZrich_repr_resultr   args
class_namer   r   r   r   r   r   r   Z
child_noder   r   r>   Zrepr_callableZobj_idr   Zcontainer_typer   r   r   Z	num_itemsZlast_item_indexZ
iter_itemsindexiter_values)	_traversern   rC   pop_visitedpush_visitedr   visited_idsr   r3   r   .  sX  &



















ztraverse.<locals>._traverseT)r   N)Fr   )r   r   setaddremovera   r   r   )rp   rC   rD   rn   r   r2   )r   rn   rC   rD   r   r   r   r   r3   traverse  s   , br   r   rj   ru   rv   rk   c          	      C   s4   t | tr| }nt| |||d}|j|||d}|S )a  Prettify repr string by expanding on to new lines to fit within a given width.

    Args:
        _object (Any): Object to repr.
        max_width (int, optional): Desired maximum width of repr string. Defaults to 80.
        indent_size (int, optional): Number of spaces to indent. Defaults to 4.
        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to None.
        max_string (int, optional): Maximum length of string before truncating, or None to disable truncating.
            Defaults to None.
        max_depth (int, optional): Maximum depth of nested data structure, or None for no depth.
            Defaults to None.
        expand_all (bool, optional): Expand all containers regardless of available width. Defaults to False.

    Returns:
        str: A possibly multi-line representation of the object.
    )rC   rD   rn   )rv   rk   rE   )rK   r   r   r   )	rp   rv   rk   rC   rD   rn   rE   r   r   r2   r2   r3   r{     s   
r{   T)r?   rB   rC   rD   rn   rE   c             
   C   s6   |du rt  n|}|jt| |||||dddd dS )a  A convenience function for pretty printing.

    Args:
        _object (Any): Object to pretty print.
        console (Console, optional): Console instance, or None to use default. Defaults to None.
        max_length (int, optional): Maximum length of containers before abbreviating, or None for no abbreviation.
            Defaults to None.
        max_string (int, optional): Maximum length of strings before truncating, or None to disable. Defaults to None.
        max_depth (int, optional): Maximum depth for nested data structures, or None for unlimited depth. Defaults to None.
        indent_guides (bool, optional): Enable indentation guides. Defaults to True.
        expand_all (bool, optional): Expand all containers. Defaults to False.
    Nr=   )rC   rD   rn   rB   rE   r@   T)	soft_wrap)r   rQ   rR   )rp   r?   rB   rC   rD   rn   rE   _consoler2   r2   r3   rY   ;  s   	
rY   __main__c                   @   s   e Zd ZdefddZdS )
BrokenReprr.   c                 C   s   dd  dS )Nr   r   zthis will failr2   r   r2   r2   r3   r6   c  s   zBrokenRepr.__repr__N)r^   r_   r`   r   r6   r2   r2   r2   r3   r  b  s    r     foozHello World!gZd;Y@gʡE3t@g    cA>   r   r   r   rj   r  r         >   r   r   r   Zcrumble)appleZrhubarbbutterZsugarZflour)r	  Zorangepearkumquatr  AX  duriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurianduriandurian)FTN)r  Zbarr   ZcounterZatomicZBroken)rQ      )rB   rD   )Nr=   FFNNF)NNN)erU   r9   rN   osrerf   r   collectionsr   r   r   r   r   r   r	   r
   r   	itertoolsr   typesr   typingr   r   r   r   r   r   r   r   r   r   r   Zpip._vendor.rich.reprr   r   r/   ImportErrorrz   r   _loopr   _pickr   abcr   cellsr!   rq   r"   jupyterr#   r$   measurer%   r   r&   r?   r'   r(   r)   r*   r+   r,   ra   r4   r5   objectr<   r   rT   ri   rR   r   r   r   _Environdict	frozensetr   r   r   r   r0   rb   keysr   r   r   r   r   r   r{   rY   r^   r  ddatar   rd   rQ   r2   r2   r2   r3   <module>   s  
 4 
	
A
K$f
(
SE
  	
+	

%

