Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/jsonschema/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/jsonschema/__pycache__/exceptions.cpython-311.pyc

�

�܋f�(����dZddlmZmZddlZddlZddlZddlZddlm	Z	ddl
mZmZe
ddg��Ze
��Ze	j��ZGd�d	e��ZGd
�de��ZGd�d
e��Zejd���Gd�de����ZGd�de��ZGd�de��ZGd�de��ZGd�de��Zeefd�Ze��Zefd�ZdS)z2
Validation errors, and some surrounding helpers.
�)�defaultdict�dequeN)�_utils)�PY3�	iteritems�anyOf�oneOfc	���eZdZedddeeeddf	�fd�	Zd�Zd�ZereZnd�Ze	d���Z
ed���Zed	���Z
d
�Zd�Z�xZS)�_Error�Nc���tt|���|||||||||	|
�
�
||_t	|��x|_|_t	|	��x|_|_t|��|_
|x|_|_||_
||_||_||_|
|_|D]	}||_�
dS�N)�superr�__init__�messager�path�
relative_path�schema_path�relative_schema_path�list�context�cause�	__cause__�	validator�validator_value�instance�schema�parent)
�selfrrrrrrrrrr�error�	__class__s
            ��L/opt/cloudlinux/venv/lib64/python3.11/site-packages/jsonschema/exceptions.pyrz_Error.__init__s����	�f�d���$�$�����������	
�	
�	
����).�t���4��	�D�&�7<�[�7I�7I�I���4�4��G�}�}���&+�+��
�T�^�"���.��� ��
��������	 �	 �E��E�L�L�	 �	 �c�2�d|jj�d|j�d�S)N�<z: �>)r!�__name__r�rs r"�__repr__z_Error.__repr__=s ���!�^�4�4�4�d�l�l�l�C�Cr#c�>�|j|j|j|jf}t	d�|D����r|jSt
j|jd���}t
j|jd���}|jtj	d�
����|j|jtj
t|j��dd���tj|��|jtj
|j��tj|��fzzS)Nc3�(K�|]
}|tuV��dSr)�_unset)�.0�ms  r"�	<genexpr>z%_Error.__unicode__.<locals>.<genexpr>Ds&����:�:�q�q�F�{�:�:�:�:�:�:r#�H��widthzl

            Failed validating %r in %s%s:
            %s

            On %s%s:
            %s
            ���)rrrr�anyr�pprint�pformat�textwrap�dedent�rstrip�!_word_for_schema_in_error_messager�format_as_indexrr�indent�#_word_for_instance_in_error_messager)r�essential_for_verbose�pschema�	pinstances    r"�__unicode__z_Error.__unicode__@s	���N�D�0�$�-���!
���:�:�$9�:�:�:�:�:�	 ��<���.���B�7�7�7���N�4�=��;�;�;�	��|�h�o�/�����
�
�
�N��2��"�4��(A�#B�#B�3�B�3�#G�H�H��M�'�"�"��4��"�4�#5�6�6��M�)�$�$�
�
�
�	
r#c�F�t|���d��S�Nzutf-8��unicode�encoder(s r"�__str__z_Error.__str__^����4�=�=�'�'��0�0�0r#c�6�|di|�����S)Nr��	_contents)�cls�others  r"�create_fromz_Error.create_fromas"���s�'�'�U�_�_�&�&�'�'�'r#c��|j}|�|jSt|j��}|�t	|j����|Sr)rrr�
extendleft�reversed�
absolute_path�rrrs   r"rRz_Error.absolute_pathesI������>��%�%��T�'�(�(�������!5�6�6�7�7�7��r#c��|j}|�|jSt|j��}|�t	|j����|Sr)rrrrPrQ�absolute_schema_pathrSs   r"rUz_Error.absolute_schema_pathosI������>��,�,��T�.�/�/�������!<�=�=�>�>�>��r#c��t|��D]-\}}t||��turt|||���.dSr)r�getattrr,�setattr)r�kwargs�k�vs    r"�_setz_Error._setysO���f�%�%�	$�	$�D�A�q��t�Q���6�)�)���a��#�#�#��	$�	$r#c�>��d}t�fd�|D����S)N)
rrrrrrrrrrc3�<�K�|]}|t�|��fV��dSr)rW)r-�attrrs  �r"r/z#_Error._contents.<locals>.<genexpr>�s2�����B�B�D�T�7�4��.�.�/�B�B�B�B�B�Br#)�dict)r�attrss` r"rKz_Error._contents~s/���
���B�B�B�B�E�B�B�B�B�B�Br#)r'�
__module__�__qualname__r,rr)rArrG�classmethodrN�propertyrRrUr\rK�
__classcell__�r!s@r"rrs��������
��������% �% �% �% �% �% �ND�D�D�
�
�
�6�1����	1�	1�	1��(�(��[�(�����X������X��$�$�$�
C�C�C�C�C�C�Cr#rc��eZdZdZdZdZdS)�ValidationErrorz:
    An instance was invalid under a provided schema.
    rrN�r'rbrc�__doc__r:r=rr#r"riri�s(��������)1�%�*4�'�'�'r#ric��eZdZdZdZdZdS)�SchemaErrorzB
    A schema was invalid under its corresponding metaschema.
    �
metaschemarNrjrr#r"rmrm�s(��������)5�%�*2�'�'�'r#rmT)�hashc�6�eZdZdZej��Zd�ZdS)�RefResolutionErrorz&
    A ref could not be resolved.
    c�*�t|j��Sr)�str�_causer(s r"rGzRefResolutionError.__str__�s���4�;���r#N)r'rbrcrkr_�ibrtrGrr#r"rqrq�s<���������T�W�Y�Y�F� � � � � r#rqc�0�eZdZdZd�Zd�ZereZdSd�ZdS)�UndefinedTypeCheckzN
    A type checker was asked to check a type it did not have registered.
    c��||_dSr��type)rrzs  r"rzUndefinedTypeCheck.__init__�s
����	�	�	r#c��d|jzS)Nz'Type %r is unknown to this type checkerryr(s r"rAzUndefinedTypeCheck.__unicode__�s��8�4�9�D�Dr#c�F�t|���d��SrCrDr(s r"rGzUndefinedTypeCheck.__str__�rHr#N�r'rbrcrkrrArrGrr#r"rwrw�sa�����������E�E�E��1�����	1�	1�	1�	1�	1r#rwc�0�eZdZdZd�Zd�ZereZdSd�ZdS)�UnknownTypezP
    A validator was asked to validate an instance against an unknown type.
    c�0�||_||_||_dSr)rzrr)rrzrrs    r"rzUnknownType.__init__�s����	� ��
�����r#c��tj|jd���}tj|jd���}t	jd�����|jtj	|��tj	|��fzS)Nr0r1z�
            Unknown type %r for validator with schema:
            %s

            While checking instance:
            %s
            )
r5r6rrr7r8r9rzrr<)rr?r@s   r"rAzUnknownType.__unicode__�s{���.���B�7�7�7���N�4�=��;�;�;�	��� �����

�
��Y��
�g�.�.��
�i�0H�0H�I�J�	Jr#c�F�t|���d��SrCrDr(s r"rGzUnknownType.__str__�rHr#Nr}rr#r"rr�sa�����������

J�
J�
J��1�����	1�	1�	1�	1�	1r#rc�@��eZdZdZd�fd�	Zd�ZereZ�xZSd�Z�xZS)�FormatErrorz%
    Validating a format failed.
    Nc���tt|���||��||_|x|_|_dSr)rr�rrrr)rrrr!s   �r"rzFormatError.__init__�s<���
�k�4� � �)�)�'�5�9�9�9����&+�+��
�T�^�^�^r#c��|jSr)rr(s r"rAzFormatError.__unicode__�s
���|�r#c�6�|j�d��SrC)rrFr(s r"rGzFormatError.__str__�s���<�&�&�w�/�/�/r#r)	r'rbrcrkrrArrGrfrgs@r"r�r��s|���������,�,�,�,�,�,�
����0�������	0�	0�	0�	0�	0�	0�	0r#r�c�X�eZdZdZeZdd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Ze
d
���ZdS)
�	ErrorTreezF
    ErrorTrees make it easier to check which validations failed.
    rc��i|_t|j��|_|D]1}|}|jD]
}||}�||j|j<|j|_�2dSr)�errorsrr!rKrrr�	_instance)rr�r �	container�elements     r"rzErrorTree.__init__�sq�����$�T�^�4�4����	1�	1�E��I� �:�
/�
/��%�g�.�	�	�05�I��U�_�-�"'�.�I���
	1�	1r#c��||jvS)zC
        Check whether ``instance[index]`` has any errors.
        rJ�r�indexs  r"�__contains__zErrorTree.__contains__�s��
���&�&r#c�Z�|jtur||vr
|j||j|S)a\
        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 `exceptions.LookupError`.
        )r�r,rKr�s  r"�__getitem__zErrorTree.__getitem__s5���>��'�'�E��,=�,=��N�5�!�!��~�e�$�$r#c��||j|<dS)zB
        Add an error to the tree at the given ``index``.
        NrJ)rr��values   r"�__setitem__zErrorTree.__setitem__s��!&���u���r#c�*�t|j��S)zY
        Iterate (non-recursively) over the indices in the instance with errors.
        )�iterrKr(s r"�__iter__zErrorTree.__iter__s��
�D�N�#�#�#r#c��|jS)z,
        Return the `total_errors`.
        )�total_errorsr(s r"�__len__zErrorTree.__len__s
��� � r#c�B�d|jj�dt|���d�S)Nr%z (z total errors)>)r!r'�lenr(s r"r)zErrorTree.__repr__"s$���+/�>�+B�+B�+B�C��I�I�I�I�N�Nr#c��td�t|j��D����}t|j��|zS)zT
        The total number of errors in the entire tree, including children.
        c3�:K�|]\}}t|��V��dSr)r�)r-�_�trees   r"r/z)ErrorTree.total_errors.<locals>.<genexpr>+s,����N�N���D�3�t�9�9�N�N�N�N�N�Nr#)�sumrrKr�r�)r�child_errorss  r"r�zErrorTree.total_errors%s?���N�N�I�d�n�4M�4M�N�N�N�N�N���4�;���,�.�.r#N)r)r'rbrcrkr,r�rr�r�r�r�r�r)rer�rr#r"r�r��s����������I�
1�
1�
1�
1�'�'�'�%�%�%�&�&�&�$�$�$�!�!�!�O�O�O��/�/��X�/�/�/r#r�c������fd�}|S)aq
    Create a key function that can be used to sort errors by relevance.

    Arguments:
        weak (set):
            a collection of validator names 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 validator names, the other
            error will take priority. By default, :validator:`anyOf` and
            :validator:`oneOf` are considered weak validators and will
            be superseded by other same-level validation errors.

        strong (set):
            a collection of validator names to consider to be "strong"
    c�J��|j}t|j��|�v|�vfSr)rr�r)r r�strong�weaks  ��r"�	relevancezby_relevance.<locals>.relevance?s,����O�	��E�J�����$�!6�	�V�8K�K�Kr#r)r�r�r�s`` r"�by_relevancer�/s0���� L�L�L�L�L�L��r#c���t|��}t|d��}|�dSttj|g|��|���}|jrt
|j|���}|j�|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 :validator:`oneOf` or :validator:`anyOf`,
    the *opposite* assumption is made -- i.e. the deepest error is picked,
    since these validators only need to match once, and any other errors may
    not be relevant.

    Arguments:
        errors (collections.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.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��next�max�	itertools�chainr�min)r�r��bests   r"�
best_matchr�Hsx��L�&�\�\�F������D��|����y���v�v�.�.�C�8�8�8�D�
�,�*��4�<�S�)�)�)���,�*��Kr#) rk�collectionsrrr�r5r7r_�
jsonschemar�jsonschema.compatrr�	frozenset�WEAK_MATCHES�STRONG_MATCHES�Unsetr,�	Exceptionrrirm�srqrwrr��objectr�r�r�r�rr#r"�<module>r�sy����+�*�*�*�*�*�*�*�����
�
�
�
���������������,�,�,�,�,�,�,�,��y�'�7�+�,�,�������	������nC�nC�nC�nC�nC�Y�nC�nC�nC�b5�5�5�5�5�f�5�5�5�3�3�3�3�3�&�3�3�3����T���� � � � � �� � ��� �1�1�1�1�1��1�1�1�$1�1�1�1�1�)�1�1�1�:0�0�0�0�0�)�0�0�0�(E/�E/�E/�E/�E/��E/�E/�E/�P#�>�����,
�L�N�N�	�%�.�.�.�.�.�.r#

Hacked By AnonymousFox1.0, Coded By AnonymousFox