HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.60.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Nov 5 05:00:59 EST 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //var/opt/nydus/ops/jsonschema/__pycache__/exceptions.cpython-39.pyc
a

�,�h�;�@s�UdZddlmZddlmZmZddlmZddlm	Z	m
Z
ddlmZm
Z
mZddlZddlZddlZddlmZdd	lmZdd
lmZer�ddlmZmZmZmZddlmZed
dg�Z de!d<e�Z"de!d<e�#d�Z$e�%�Z&ddd�dd�Z'dd�Z(Gdd�de)�Z*Gdd�de*�Z+Gdd�de*�Z,ed d!�Gd"d#�d#e)��Z-Gd$d%�d%e-e�Z.Gd&d'�d'e)�Z/Gd(d)�d)e)�Z0Gd*d+�d+e)�Z1Gd,d-�d-�Z2e e"fd.d/�Z3e3�Z4e4fd0d1�Z5dS)2z2
Validation errors, and some surrounding helpers.
�)�annotations)�defaultdict�deque)�pformat)�dedent�indent)�
TYPE_CHECKING�Any�ClassVarN)�define)�Unresolvable)�_utils)�Iterable�Mapping�MutableMapping�Sequence)�_typesZanyOf�oneOfzfrozenset[str]�WEAK_MATCHES�STRONG_MATCHESz^[a-zA-Z][a-zA-Z0-9_]*$r	�str��thing�prefixcCstt|ddd�|���S)zP
    Format something for an error message as prettily as we currently can.
    �HF)�width�
sort_dicts)rr�lstripr�r�F/opt/nydus/tmp/pip-target-wkfpz8uv/lib/python/jsonschema/exceptions.py�_pretty sr cCs6|dkrtjtjtdd�tStdt�d|����dS)NZRefResolutionError���
stacklevelzmodule z has no attribute )�warnings�warn�_RefResolutionError�_DEPRECATION_MESSAGE�DeprecationWarning�AttributeError�__name__)�namerrr�__getattr__'s�r,c
s�eZdZUded<ded<edddeeeddef
ddddd	d	d
dddd
d��fdd�
Zdd�dd�Zdd�dd�Zedd�dd��Z	e
dd�dd��Ze
dd�dd��Ze
dd�dd��Z
d)d d	d
d!�d"d#�Zd$d%�Zd&d�d'd(�Z�ZS)*�_Errorz
ClassVar[str]�!_word_for_schema_in_error_message�#_word_for_instance_in_error_messagerNrzIterable[str | int]zException | Noner	zMapping[str, Any] | boolz
_Error | Nonez_types.TypeChecker�None)�message�	validator�path�cause�validator_value�instance�schema�schema_path�parent�type_checker�returnc
s�t��|||||||||	|
�
||_t|�|_|_t|	�|_|_t|�|_	||_
|_||_||_
||_||_|
|_||_|D]
}||_q�dS�N)�super�__init__r1rr3�
relative_pathr8�relative_schema_path�list�contextr4�	__cause__r2r5r6r7r9�
_type_checker)
�selfr1r2r3r4rBr5r6r7r8r9r:�error��	__class__rrr>7s2�
z_Error.__init__�r;cCsd|jj�d|j�d�S)N�<�: �>)rHr*r1�rErrr�__repr__`sz_Error.__repr__cCs�|j|j|j|jf}tdd�|D��r,|jStj|jt	|j
�dd�d�}tj|j|jd�}d}t
d|j�d|j�d|�d	t|j|d
��d|�d	t|j|d
��d�
���S)
Ncss|]}|tuVqdSr<)�_unset)�.0�mrrr�	<genexpr>g�z!_Error.__str__.<locals>.<genexpr>���)�	container�indices�                z            z 

            Failed validating z in z:
                �rz

            On �
            )r2r5r6r7�anyr1r
Zformat_as_indexr.rAr@r/r?rr �rstrip)rEZessential_for_verboser8Z
instance_pathrrrr�__str__cs8���������
�z_Error.__str__)�othercCs|fi|����Sr<��	_contents)�clsr]rrr�create_from�sz_Error.create_fromzSequence[str | int]cCs2|j}|dur|jSt|j�}|�t|j��|Sr<)r9r?r�
extendleft�reversed�
absolute_path�rEr9r3rrrrd�s
z_Error.absolute_pathcCs2|j}|dur|jSt|j�}|�t|j��|Sr<)r9r@rrbrc�absolute_schema_pathrerrrrf�s
z_Error.absolute_schema_pathcCspd}|jD]`}t|t�r.|dt|�d7}q
t�|�rF|d|7}q
|�dd��dd�}|d	|d
7}q
|S)N�$�[�]�.�\z\\�'z\'z['z'])rd�
isinstance�intr�&_JSON_PATH_COMPATIBLE_PROPERTY_PATTERN�match�replace)rEr3�elemZescaped_elemrrr�	json_path�s


z_Error.json_pathz_types.TypeChecker | None)r:�kwargsr;cKsH|dur|jtur||_|��D]"\}}t||�tur t|||�q dSr<)rDrO�items�getattr�setattr)rEr:rt�k�vrrr�_set�s
z_Error._setcsd}�fdd�|D�S)N)
r1r4rBr2r5r3r8r6r7r9csi|]}|t�|��qSr)rv)rP�attrrMrr�
<dictcomp>�rSz$_Error._contents.<locals>.<dictcomp>r)rE�attrsrrMrr_�sz_Error._contents�boolc	sXz�jd}Wnttfy&YdS0t|t�rB�j��j|�St�fdd�|D��S)N�typeFc3s|]}�j��j|�VqdSr<)rD�is_typer6)rP�
expected_typerMrrrR�s�z'_Error._matches_type.<locals>.<genexpr>)	r7�KeyError�	TypeErrorrmrrDr�r6rZ)rE�expectedrrMr�
_matches_type�s
�z_Error._matches_type)N)r*�
__module__�__qualname__�__annotations__rOr>rNr\�classmethodra�propertyrdrfrsrzr_r��
__classcell__rrrGrr-2s6
�()		�r-c@seZdZdZdZdZdS)�ValidationErrorz:
    An instance was invalid under a provided schema.
    r7r6N�r*r�r��__doc__r.r/rrrrr��sr�c@seZdZdZdZdZdS)�SchemaErrorzB
    A schema was invalid under its corresponding metaschema.
    Z
metaschemar7Nr�rrrrr��sr�F)�slotsc@s4eZdZUdZdZded<dd�Zdd�d	d
�ZdS)r&z&
    A ref could not be resolved.
    z�jsonschema.exceptions.RefResolutionError is deprecated as of version 4.18.0. If you wish to catch potential reference resolution errors, directly catch referencing.exceptions.Unresolvable.�	Exception�_causecCs|j|jurtS|j|jkSr<)rH�NotImplementedr��rEr]rrr�__eq__�sz_RefResolutionError.__eq__rrIcCs
t|j�Sr<)rr�rMrrrr\�sz_RefResolutionError.__str__N)r*r�r�r�r'r�r�r\rrrrr&�s
�r&c@sBeZdZdd�dd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)�_WrappedReferencingError�
_Unresolvable)r4cCst�|d|�dS)N�_wrapped)�object�__setattr__)rEr4rrrr>�sz!_WrappedReferencingError.__init__cCs4|j|jur|j|jkS|j|jjur0|j|kStSr<)rHr�r�r�rrrr��s

z_WrappedReferencingError.__eq__cCst|j|�Sr<)rvr�)rEr{rrrr,�sz$_WrappedReferencingError.__getattr__cCs
t|j�Sr<)�hashr�rMrrr�__hash__�sz!_WrappedReferencingError.__hash__cCsd|j�d�S)Nz<WrappedReferencingError rL)r�rMrrrrNsz!_WrappedReferencingError.__repr__cCs|jjj�d|j��S)NrK)r�rHr*rMrrrr\sz _WrappedReferencingError.__str__N)	r*r�r�r>r�r,r�rNr\rrrrr��sr�c@s.eZdZdZddd�dd�Zdd�dd	�Zd
S)�UndefinedTypeCheckzN
    A type checker was asked to check a type it did not have registered.
    rr0)rr;cCs
||_dSr<�r)rErrrrr>szUndefinedTypeCheck.__init__rIcCsd|j�d�S)NzType z  is unknown to this type checkerr�rMrrrr\szUndefinedTypeCheck.__str__N�r*r�r�r�r>r\rrrrr�	sr�c@s eZdZdZdd�Zdd�ZdS)�UnknownTypezP
    A validator was asked to validate an instance against an unknown type.
    cCs||_||_||_dSr<)rr6r7)rErr6r7rrrr>szUnknownType.__init__c
Cs:d}td|j�dt|j|d��dt|j|d��d����S)NrWz            Unknown type z, for validator with schema:
                rXz7

            While checking instance:
                rY)rrr r7r6r[)rErrrrr\s���
�zUnknownType.__str__Nr�rrrrr�sr�cs*eZdZdZd�fdd�	Zdd�Z�ZS)�FormatErrorz%
    Validating a format failed.
    Ncs$t��||�||_||_|_dSr<)r=r>r1r4rC)rEr1r4rGrrr>2szFormatError.__init__cCs|jSr<)r1rMrrrr\7szFormatError.__str__)N)r*r�r�r�r>r\r�rrrGrr�-sr�c@sneZdZdZeZddd�dd�Zdd�d	d
�Zdd�Zddd
�dd�Z	dd�Z
dd�Zdd�Ze
dd��ZdS)�	ErrorTreezF
    ErrorTrees make it easier to check which validations failed.
    rzIterable[ValidationError])�errorscCsLi|_t|j�|_|D]0}|}|jD]}||}q$||j|j<|j|_qdSr<)r�rrHr_r3r2r6�	_instance)rEr�rFrU�elementrrrr>Bs

zErrorTree.__init__z	str | int)�indexcCs
||jvS)zC
        Check whether ``instance[index]`` has any errors.
        r^�rEr�rrr�__contains__NszErrorTree.__contains__cCs&|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�rOr_r�rrr�__getitem__Ts	
zErrorTree.__getitem__)r��valuecCstjdtdd�||j|<dS)a
        Add an error to the tree at the given ``index``.

        .. deprecated:: v4.20.0

            Setting items on an `ErrorTree` is deprecated without replacement.
            To populate a tree, provide all of its sub-errors when you
            construct the tree.
        z8ErrorTree.__setitem__ is deprecated without replacement.r!r"N)r$r%r(r_)rEr�r�rrr�__setitem__as
�zErrorTree.__setitem__cCs
t|j�S)zY
        Iterate (non-recursively) over the indices in the instance with errors.
        )�iterr_rMrrr�__iter__rszErrorTree.__iter__cCs|jS)z,
        Return the `total_errors`.
        )�total_errorsrMrrr�__len__xszErrorTree.__len__cCs4t|�}|dkrdnd}d|jj�d|�d|�d�S)N�rFr�rJz (z total z)>)�lenrHr*)rE�totalr�rrrrN~szErrorTree.__repr__cCs&tdd�|j��D��}t|j�|S)zT
        The total number of errors in the entire tree, including children.
        css|]\}}t|�VqdSr<)r�)rP�_�treerrrrR�rSz)ErrorTree.total_errors.<locals>.<genexpr>)�sumr_rur�r�)rEZchild_errorsrrrr��szErrorTree.total_errorsN)r)r*r�r�r�rOr�r>r�r�r�r�r�rNr�r�rrrrr�;s
r�cs��fdd�}|S)a{
    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"

    cs,|j}t|j�|j|�v|�v|��fSr<)r2r�r3r�)rFr2��strong�weakrr�	relevance�s
�zby_relevance.<locals>.relevancer)r�r�r�rr�r�by_relevance�s
r�cCsht||dd�}|durdS|jrdtjd|j|d�}t|�dkrZ||d�||d�krZ|S|d}q|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�defaultr!)r�rr�)�maxrB�heapq�	nsmallestr�)r�r��bestZsmallestrrr�
best_match�s'$
r�)6r��
__future__r�collectionsrr�pprintr�textwraprr�typingrr	r
r��rer$r}rZreferencing.exceptionsrr�Z
jsonschemar
�collections.abcrrrrr�	frozensetrr�r�compileroZUnsetrOr r,r�r-r�r�r&r�r�r�r�r�r�r�r�rrrr�<module>sD
		Q