
    bMh                        U d Z ddlmZ ddlZddlZddlmZ ddlZddlm	Z	 ddl
mZ ddlmZ ej        rd	Zd
ed<   dZd
ed<    G d de          Z G d d          ZddZdS )z:Tools to provide pretty/human-readable display of objects.    )annotationsN)Any)typing_objects)is_union_origin   )_typing_extraz'typing.Iterable[tuple[str | None, Any]]ztyping_extensions.TypeAliasReprArgszJtyping.Iterable[Any | tuple[Any] | tuple[str, Any] | tuple[str, Any, Any]]RichReprResultc                      e Zd ZdZddZdS )	PlainReprzString class where repr doesn't include quotes. Useful with Representation when you want to return a string
    representation of something that is valid (or pseudo-valid) python.
    returnstrc                     t          |           S N)r   selfs    X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/pydantic/_internal/_repr.py__repr__zPlainRepr.__repr__   s    4yy    Nr   r   )__name__
__module____qualname____doc__r    r   r   r   r      s2              r   r   c                  R    e Zd ZdZddZddZdd	ZddZddZddZ	ddZ
ddZdS )Representationr   r   r	   c                      j         }|s)t           d          r j                                        } fd|D             } fd|D             S )a-  Returns the attributes to show in __str__, __repr__, and __pretty__ this is generally overridden.

        Can either return:
        * name - value pairs, e.g.: `[('foo_name', 'foo'), ('bar_name', ['b', 'a', 'r'])]`
        * or, just values, e.g.: `[(None, 'foo'), (None, ['b', 'a', 'r'])]`
        __dict__c              3  <   K   | ]}|t          |          fV  d S r   )getattr).0sr   s     r   	<genexpr>z/Representation.__repr_args__.<locals>.<genexpr>2   s2      <<1!WT1%%&<<<<<<r   c                T    g | ]$\  }}|||ur|n                     |          f%S r   )__repr_recursion__)r"   avr   s      r   
<listcomp>z0Representation.__repr_args__.<locals>.<listcomp>3   sB    kkkDAq]^]j$AAD,C,CA,F,FG]j]j]jr   )	__slots__hasattrr   keys)r   attrs_namesattrss   `  r   __repr_args__zRepresentation.__repr_args__(   sl     n 	/wtZ88 	/-,,..K<<<<<<<kkkkTYkkkkr   r   c                    | j         j        S )z/Name of the instance's class, used in __repr__.)	__class__r   r   s    r   __repr_name__zRepresentation.__repr_name__5   s    ~&&r   objectr   c                R    dt          |          j         dt          |           dS )z8Returns the string representation of a recursive object.z<Recursion on z	 with id=>)typer   id)r   r3   s     r   r&   z!Representation.__repr_recursion__9   s-     NV 5MM6

MMMMr   join_strc                d    |                     d |                                 D                       S )Nc              3  L   K   | ]\  }}|t          |          n| d|V   d S )N=)repr)r"   r'   r(   s      r   r$   z.Representation.__repr_str__.<locals>.<genexpr>?   s>      ee1	T!WWW!||a||eeeeeer   )joinr/   )r   r8   s     r   __repr_str__zRepresentation.__repr_str__>   s0    }}eePTPbPbPdPdeeeeeer   fmttyping.Callable[[Any], Any]kwargs!typing.Generator[Any, None, None]c              +     K   |                                  dz   V  dV  |                                 D ]#\  }}||dz   V   ||          V  dV  dV  $dV  dV  dS )	zRUsed by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.(r   Nr;   ,r   ))r2   r/   )r   r?   rA   namevalues        r   
__pretty__zRepresentation.__pretty__A   s        ""S((((--// 	 	KD%Sj   #e**IIIGGGG					r   r
   c              #  X   K   |                                  D ]\  }}||V  ||fV  dS )zYUsed by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.N)r/   )r   rH   
field_reprs      r   __rich_repr__zRepresentation.__rich_repr__N   sX       $ 2 2 4 4 	' 	'D*|     J&&&&&		' 	'r   c                ,    |                      d          S )N )r>   r   s    r   __str__zRepresentation.__str__V   s      %%%r   c                \    |                                   d|                     d           dS )NrD   , rG   )r2   r>   r   s    r   r   zRepresentation.__repr__Y   s3    $$&&CC):):4)@)@CCCCr   N)r   r	   r   )r3   r   r   r   )r8   r   r   r   )r?   r@   rA   r   r   rB   )r   r
   )r   r   r   r*   r/   r2   r&   r>   rJ   rM   rP   r   r   r   r   r   r      s         Il l l l' ' ' 'N N N N
f f f f   ' ' ' '& & & &D D D D D Dr   r   objr   r   r   c                   t          | t          j        t          j        f          r| j        S | du rdS t          | t
                    rt          |           S t          | t          j                  st          j
        |           rt          |           S t          | t          j        t          j        t          f          s| j        } t#          t%          j        |                     r@d                    t+          t,          t%          j        |                               }d| dS t          | t          j                  rt          j        t%          j        |                     r;d                    t+          t          t%          j        |                               }n:d                    t+          t,          t%          j        |                               }	 | j         d| dS # t4          $ r: t          |                               dd                              d	d          cY S w xY wt          | t                    r| j        S t          |                               dd                              d	d          S )
zPretty representation of a type, should be as close as possible to the original type definition string.

    Takes some logic from `typing._type_repr`.
    .z...rR   zUnion[][ztyping. ztyping_extensions.)
isinstancetypesFunctionTypeBuiltinFunctionTyper   r   r<   typing
ForwardRefr   is_typealiastyper   r   typing_baseWithArgsTypesr6   r1   r   typing_extensions
get_originr=   mapdisplay_as_typeget_args
is_literalr   AttributeErrorreplace)rS   argss     r   rd   rd   ]   sE   
 #*E,EFGG |	u	C	(	( Cyy	C*	+	+ ~/Ns/S/S 3xxcM5}7RTXYZZ m(3C8899 Ryy_.?.H.M.MNNOO	C4	5	5 R$%6%A#%F%FGG 	T99S'8'A#'F'FGGHHDD99S2C2LS2Q2QRRSSD	U&000000 	U 	U 	Us88##Ir22::;OQSTTTTT	U	C		 RCyy  B//778LbQQQs   G, ,AH0/H0)rS   r   r   r   )r   
__future__r   _annotationsrY   r\   r   ra   typing_inspectionr   typing_inspection.introspectionr   rW   r   TYPE_CHECKINGr	   __annotations__r
   r   r   r   rd   r   r   r   <module>rp      s=   @ @ @ 2 2 2 2 2 2             , , , , , , ; ; ; ; ; ;      	 ,UHUUUUT     
       ;D ;D ;D ;D ;D ;D ;D ;D| R  R  R  R  R  Rr   