%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/jsonschema/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/jsonschema/__pycache__/exceptions.cpython-312.pyc

�

`��d,���UdZddlmZddlmZmZddlmZddlm	Z	m
Z
ddlZddlZddl
Z
ddlmZedd	g�Zd
ed<e�Zd
ed<ej(�ZGd
�de�ZGd�de�ZGd�de�Ze
j4d��Gd�de��ZGd�de�ZGd�de�ZGd�de�ZGd�de�Z eefd�Z!e!�Z"e"fd �Z#y)!z2
Validation errors, and some surrounding helpers.
�)�annotations)�defaultdict�deque)�pformat)�dedent�indentN)�_utils�anyOf�oneOfzfrozenset[str]�WEAK_MATCHES�STRONG_MATCHESc
���eZdZedddeeeddef
�fd�	Zd�Zd�Zed��Ze	d��Z
e	d��Ze	d	��Zd
d
�Z
d�Zd�Z�xZS)�_Error�Nc�T��tt|�|||||||||	|
�
||_t	|�x|_|_t	|	�x|_|_t|�|_
|x|_|_||_
||_||_||_|
|_||_|D]	}||_�y�N)�superr�__init__�messager�path�
relative_path�schema_path�relative_schema_path�list�context�cause�	__cause__�	validator�validator_value�instance�schema�parent�
_type_checker)�selfrrrrrrr r!rr"�type_checker�error�	__class__s             ��7/usr/lib/python3/dist-packages/jsonschema/exceptions.pyrz_Error.__init__s����	�f�d�$�����������	
����).�t��4��	�D�&�7<�[�7I�I���4�4��G�}���&+�+��
�T�^�"���.��� ��
�������)����	 �E��E�L�	 �c�P�d|jj�d|j�d�S)N�<z: �>)r'�__name__r�r$s r(�__repr__z_Error.__repr__@s'���4�>�>�*�*�+�2�d�l�l�-=�Q�?�?r)c��|j|j|j|jf}t	d�|D��r|j
St
j|jt|j�dd��}t
j|j|j��}d}td|j
�d|j�d|�dtt|jd	�
�|�j!��d|�dtt|jd	�
�|�j!��d�
j#��S)
Nc3�,K�|]}|tu���y�wr)�_unset)�.0�ms  r(�	<genexpr>z!_Error.__str__.<locals>.<genexpr>Gs����:�q�q�F�{�:�s����)�	container�indices�                z            z 

            Failed validating z in z:
                �H��widthz

            On �
            )rrr r!�anyrr	�format_as_index�!_word_for_schema_in_error_messagerr�#_word_for_instance_in_error_messagerrrr�lstrip�rstrip)r$�essential_for_verboser�
instance_path�prefixs     r(�__str__z_Error.__str__Cs5���N�N�D�0�0�$�-�-����!
���:�$9�:�:��<�<���,�,��<�<���2�2�3�C�R�8�
���.�.��>�>��&�&�
�
����
�
�\�\�N��#�~�~�0��[�M�B������2�6��?�F�F�H�I�J�������
�
�R�8�&�A�H�H�J�K�L
�
����

�
	
r)c�.�|di|j���S)Nr��	_contents)�cls�others  r(�create_fromz_Error.create_from`s���'�U�_�_�&�'�'r)c��|j}|�|jSt|j�}|jt	|j
��|Sr)r"rr�
extendleft�reversed�
absolute_path�r$r"rs   r(rQz_Error.absolute_pathdsH�������>��%�%�%��T�'�'�(�������!5�!5�6�7��r)c��|j}|�|jSt|j�}|jt	|j
��|Sr)r"rrrOrP�absolute_schema_pathrRs   r(rTz_Error.absolute_schema_pathnsH�������>��,�,�,��T�.�.�/�������!<�!<�=�>��r)c��d}|jD]/}t|t�r|dt|�zdzz
}�(|d|zz
}�1|S)N�$�[�]�.)rQ�
isinstance�int�str)r$r�elems   r(�	json_pathz_Error.json_pathxsR�����&�&�	#�D��$��$���c�$�i��#�-�-����d�
�"��		#�
�r)c��|�|jtur||_|j�D]%\}}t||�tus�t	|||��'yr)r#r2�items�getattr�setattr)r$r%�kwargs�k�vs     r(�_setz_Error._set�sQ���#��(:�(:�f�(D�!-�D���L�L�N�	$�D�A�q��t�Q��6�)���a��#�	$r)c�0��d}t�fd�|D��S)N)
rrrrrrrr r!r"c3�:�K�|]}|t�|�f���y�wr)ra)r3�attrr$s  �r(r5z#_Error._contents.<locals>.<genexpr>�s�����B�D�T�7�4��.�/�B�s�)�dict)r$�attrss` r(rJz_Error._contents�s���
���B�E�B�B�Br)c����	�jd}t|t�r&�j
j
�j|�St�fd�|D��S#ttf$rYywxYw)N�typeFc3�j�K�|]*}�jj�j|����,y�wr)r#�is_typer )r3�
expected_typer$s  �r(r5z'_Error._matches_type.<locals>.<genexpr>�s0�����
��
���&�&�t�}�}�m�D�
�s�03)	r!�KeyError�	TypeErrorrZr\r#ror r>)r$�expecteds` r(�
_matches_typez_Error._matches_type�sr���	��{�{�6�*�H��h��$��%�%�-�-�d�m�m�X�F�F��
�!)�
�
�	
��
�)�$�	��	�s�A�A.�-A.r)r-�
__module__�__qualname__r2rr/rG�classmethodrM�propertyrQrTr^rfrJrt�
__classcell__�r's@r(rrs�����
���������' �R@�
�:�(��(�������������$�C�
r)rc��eZdZdZdZdZy)�ValidationErrorz:
    An instance was invalid under a provided schema.
    r!r N�r-rurv�__doc__r@rArr)r(r|r|�s���)1�%�*4�'r)r|c��eZdZdZdZdZy)�SchemaErrorzB
    A schema was invalid under its corresponding metaschema.
    �
metaschemar!Nr}rr)r(r�r��s���)5�%�*2�'r)r�T)�hashc�8�eZdZdZej
�Zd�Zy)�RefResolutionErrorz&
    A ref could not be resolved.
    c�,�t|j�Sr)r\�_causer.s r(rGzRefResolutionError.__str__�s���4�;�;��r)N)r-rurvr~ri�ibr�rGrr)r(r�r��s����T�W�W�Y�F� r)r�c��eZdZdZd�Zd�Zy)�UndefinedTypeCheckzN
    A type checker was asked to check a type it did not have registered.
    c��||_yr�rm)r$rms  r(rzUndefinedTypeCheck.__init__�s	����	r)c�"�d|j�d�S)NzType z  is unknown to this type checkerr�r.s r(rGzUndefinedTypeCheck.__str__�s���t�y�y�m�#C�D�Dr)N�r-rurvr~rrGrr)r(r�r��s����Er)r�c��eZdZdZd�Zd�Zy)�UnknownTypezP
    A validator was asked to validate an instance against an unknown type.
    c�.�||_||_||_yr)rmr r!)r$rmr r!s    r(rzUnknownType.__init__�s����	� ��
���r)c
��d}td|j�dtt|jd��|�j��dtt|jd��|�j��d�j��S)Nr9z            Unknown type z, for validator with schema:
                r:r;z7

            While checking instance:
                r=)rrmrrr!rBr rC)r$rFs  r(rGzUnknownType.__str__�s��������)�)��'������2�6��?�F�F�H�I�J����
�
�R�8�&�A�H�H�J�K�L
�
����
�	
r)Nr�rr)r(r�r��s����

r)r�c�*��eZdZdZd�fd�	Zd�Z�xZS)�FormatErrorz%
    Validating a format failed.
    c�X��tt|�||�||_|x|_|_yr)rr�rrrr)r$rrr's   �r(rzFormatError.__init__�s)���
�k�4�)�'�5�9����&+�+��
�T�^r)c��|jSr)rr.s r(rGzFormatError.__str__�s���|�|�r)r)r-rurvr~rrGryrzs@r(r�r��s����,�
r)r�c�P�eZdZdZeZdd�Zd�Zd�Zd�Z	d�Z
d�Zd�Ze
d	��Zy
)�	ErrorTreezF
    ErrorTrees make it easier to check which validations failed.
    c���i|_t|j�|_|D]D}|}|jD]}||}�	||j|j
<|j|_�Fyr)�errorsrr'rJrrr �	_instance)r$r�r&r7�elements     r(rzErrorTree.__init__�sj�����$�T�^�^�4����	1�E��I� �:�:�
/��%�g�.�	�
/�05�I���U�_�_�-�"'�.�.�I��
	1r)c��||jvS)zC
        Check whether ``instance[index]`` has any errors.
        rI�r$�indexs  r(�__contains__zErrorTree.__contains__s��
����&�&r)c�j�|jtur||vr|j||j|S)aQ
        Retrieve the child tree one level down at the given ``index``.

        If the index is not in the instance that this tree corresponds
        to and is not known by this tree, whatever error would be raised
        by ``instance.__getitem__`` will be propagated (usually this is
        some subclass of `LookupError`.
        )r�r2rJr�s  r(�__getitem__zErrorTree.__getitem__
s2���>�>��'�E��,=��N�N�5�!��~�~�e�$�$r)c�"�||j|<y)zB
        Add an error to the tree at the given ``index``.
        NrI)r$r��values   r(�__setitem__zErrorTree.__setitem__s��!&����u�r)c�,�t|j�S)zY
        Iterate (non-recursively) over the indices in the instance with errors.
        )�iterrJr.s r(�__iter__zErrorTree.__iter__s��
�D�N�N�#�#r)c��|jS)z,
        Return the `total_errors`.
        )�total_errorsr.s r(�__len__zErrorTree.__len__%s��� � � r)c�N�d|jj�dt|��d�S)Nr+z (z total errors)>)r'r-�lenr.s r(r/zErrorTree.__repr__+s&���4�>�>�*�*�+�2�c�$�i�[��H�Hr)c��td�|jj�D��}t|j�|zS)zT
        The total number of errors in the entire tree, including children.
        c3�8K�|]\}}t|����y�wr)r�)r3�_�trees   r(r5z)ErrorTree.total_errors.<locals>.<genexpr>4s����K���D�3�t�9�K�s�)�sumrJr`r�r�)r$�child_errorss  r(r�zErrorTree.total_errors.s5���K�D�N�N�4H�4H�4J�K�K���4�;�;��,�.�.r)N)r)r-rurvr~r2r�rr�r�r�r�r�r/rxr�rr)r(r�r��sF����I�
1�'�%�&�$�!�I��/��/r)r�c������fd�}|S)az
    Create a key function that can be used to sort errors by relevance.

    Arguments:
        weak (set):
            a collection of validation keywords to consider to be
            "weak".  If there are two errors at the same level of the
            instance and one is in the set of weak validation keywords,
            the other error will take priority. By default, :kw:`anyOf`
            and :kw:`oneOf` are considered weak keywords and will be
            superseded by other same-level validation errors.

        strong (set):
            a collection of validation keywords to consider to be
            "strong"
    c�v��|j}t|j�|�v|�v|j�fSr)rr�rrt)r&r�strong�weaks  ��r(�	relevancezby_relevance.<locals>.relevanceIsC����O�O�	�
����_���T�!�����#�#�%�%�	
�	
r)r)r�r�r�s`` r(�by_relevancer�8s���"
��r)c�L�t|�}t|d�}|�yttj|g|�|��}|j
r[t
jd|j
|��}t|�dk(r||d�||d�k(r|S|d}|j
r�[|S)a�
    Try to find an error that appears to be the best match among given errors.

    In general, errors that are higher up in the instance (i.e. for which
    `ValidationError.path` is shorter) are considered better matches,
    since they indicate "more" is wrong with the instance.

    If the resulting match is either :kw:`oneOf` or :kw:`anyOf`, the
    *opposite* assumption is made -- i.e. the deepest error is picked,
    since these keywords only need to match once, and any other errors
    may not be relevant.

    Arguments:
        errors (collections.abc.Iterable):

            the errors to select from. Do not provide a mixture of
            errors from different validation attempts (i.e. from
            different instances or schemas), since it won't produce
            sensical output.

        key (collections.abc.Callable):

            the key to use when sorting errors. See `relevance` and
            transitively `by_relevance` for more details (the default is
            to sort with the defaults of that function). Changing the
            default is only useful if you want to change the function
            that rates errors but still want the error context descent
            done by this function.

    Returns:
        the best matching error, or ``None`` if the iterable was empty

    .. note::

        This function is a heuristic. Its return value may change for a given
        set of inputs from version to version if better heuristics are added.
    N)�key�r�)	r��next�max�	itertools�chainr�heapq�	nsmallestr�)r�r��best�smallests    r(�
best_matchr�Ws���L�&�\�F�����D��|���y����v�v�.�C�8�D�
�,�,��?�?�1�d�l�l��<���x�=�A��#�h�q�k�"2�c�(�1�+�6F�"F��K���{��
�,�,��Kr))$r~�
__future__r�collectionsrr�pprintr�textwraprrr�r�ri�
jsonschemar	�	frozensetr�__annotations__r
�Unsetr2�	Exceptionrr|r��sr�r�r�r��objectr�r�r�r�rr)r(�<module>r�s����#�*��#�����(�'�7�);�<��n�<�!*����,�	������G
�Y�G
�T5�f�5�3�&�3�����T�� �� �� �	E��	E�
�)�
�0�)��E/��E/�P#�>��8
�N�	�%�3r)

Zerion Mini Shell 1.0