o
    "“i  ã                   @   s”   d Z ddlmZmZ ddlmZmZmZ ddgZde	dee
d	f d
efdd„Zdefdeeee	f dedee	ee
d	f gef d
ee fdd„Zd	S )zCattrs validation.é    )ÚCallableÚUnioné   )ÚClassValidationErrorÚForbiddenExtraKeysErrorÚIterableValidationErrorÚformat_exceptionÚtransform_errorÚexcÚtypeNÚreturnc                 C   s  t | tƒr	d}|S t | tƒr)|dur%t|dƒr|jnt|ƒ}d|› �}|S d}|S t | tƒrY|du rF| jd  d¡r>d}|S d	| › d
�}|S t|dƒrN|jnt|ƒ}d|› �}|S t | t	ƒrjdd 
| j¡› d
�}|S t | tƒr{| jd  d¡r{d}|S d| › d
�}|S )aÞ  The default exception formatter, handling the most common exceptions.

    The following exceptions are handled specially:

    * `KeyErrors` (`required field missing`)
    * `ValueErrors` (`invalid value for type, expected <type>` or just `invalid value`)
    * `TypeErrors` (`invalid value for type, expected <type>` and a couple special
      cases for iterables)
    * `cattrs.ForbiddenExtraKeysError`
    * some `AttributeErrors` (special cased for structing mappings)
    zrequired field missingNÚ__name__z!invalid value for type, expected zinvalid valuer   zobject is not iterablez,invalid value for type, expected an iterablezinvalid type (ú)zextra fields found (z, zobject has no attribute 'items'zexpected a mappingzunknown error ()Ú
isinstanceÚKeyErrorÚ
ValueErrorÚhasattrr   ÚreprÚ	TypeErrorÚargsÚendswithr   ÚjoinÚextra_fieldsÚAttributeError)r
   r   ÚresÚtn© r   úH/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/v.pyr      s<   

ç
ì
íòô

ö	øÿþú$Úpathc                 C   sX  g }t | tƒrP|  ¡ \}}|D ],\} }|› d|j›d�}t | ttfƒr-| t| ||ƒ¡ q| || |jƒ› d|› �¡ q|D ]} | || dƒ› d|› �¡ q>|S t | tƒr�|  ¡ \}}|D ]+\} }|› d|j	› �}t | ttfƒrz| t| ||ƒ¡ q]| || |jƒ› d|› �¡ q]|D ]} | || dƒ› d|› �¡ q‹|S | || dƒ› d|› �¡ |S )a  Transform an exception into a list of error messages.

    To get detailed error messages, the exception should be produced by a converter
    with `detailed_validation` set.

    By default, the error messages are in the form of `{description} @ {path}`.

    While traversing the exception and subexceptions, the path is formed:

    * by appending `.{field_name}` for fields in classes
    * by appending `[{int}]` for indices in iterables, like lists
    * by appending `[{str}]` for keys in mappings, like dictionaries

    :param exc: The exception to transform into error messages.
    :param path: The root path to use.
    :param format_exception: A callable to use to transform `Exceptions` into
        string descriptions of errors.

    .. versionadded:: 23.1.0
    ú[ú]z @ NÚ.)
r   r   Úgroup_exceptionsÚindexr   Úextendr	   Úappendr   Úname)r
   r   r   ÚerrorsÚ
with_notesÚwithoutÚnoteÚpr   r   r   r	   8   s.   

ôÿ)Ú__doc__Útypingr   r   r(   r   r   r   Ú__all__ÚBaseExceptionr   Ústrr   Úlistr	   r   r   r   r   Ú<module>   s$    ,ûÿþÿýú