HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/attr/__pycache__/validators.cpython-312.pyc
�

��`�,���dZddlmZmZmZddlZddlmZmZm	Z	m
Z
ddlmZgd�Z
e
dd	d	�
�Gd�de��Zd
�Ze
dd	d	��Gd�de��Zd$d�Ze
dd	d	�
�Gd�de��Zd�Ze
dd	d	�
�Gd�de��Zd�Ze
dd	d	�
�Gd�de��Zd�Ze
ddd	�
�Gd�de��Zd�Ze
dd	d	�
�Gd�de��Zd%d �Ze
dd	d	�
�Gd!�d"e��Zd%d#�Zy)&z
Commonly useful validators.
�)�absolute_import�division�print_functionN�)�
_AndValidator�and_�attrib�attrs)�NotCallableError)	r�
deep_iterable�deep_mapping�in_�instance_of�is_callable�
matches_re�optional�providesFT)�repr�slots�hashc�&�eZdZe�Zd�Zd�Zy)�_InstanceOfValidatorc���t||j�sItdj|j|j|j
|��||j|��y)�P
        We use a callable class to be able to change the ``__repr__``.
        z?'{name}' must be {type!r} (got {value!r} that is a {actual!r}).)�name�type�actual�valueN)�
isinstancer�	TypeError�formatr�	__class__��self�inst�attrrs    �1/usr/lib/python3/dist-packages/attr/validators.py�__call__z_InstanceOfValidator.__call__s_���%����+���%�v������� �?�?��	 &� ���	�	���
�,�c�:�dj|j��S)Nz)<instance_of validator for type {type!r}>�r)r!r�r$s r'�__repr__z_InstanceOfValidator.__repr__0s"��:�A�A����B�
�	
r)N)�__name__�
__module__�__qualname__r	rr(r-�r)r'rrs���8�D��$
r)rc��t|�S)a�
    A validator that raises a `TypeError` if the initializer is called
    with a wrong type for this particular attribute (checks are performed using
    `isinstance` therefore it's also valid to pass a tuple of types).

    :param type: The type to check for.
    :type type: type or tuple of types

    :raises TypeError: With a human readable error message, the attribute
        (of type `attr.Attribute`), the expected type, and the value it
        got.
    )rr+s r'rr6s�� ��%�%r))r�frozenrc�B�eZdZe�Ze�Ze�Zd�Zd�Zy)�_MatchesReValidatorc��|j|�sHtdj|j|jj
|��||j|��y)rz7'{name}' must match regex {regex!r} ({value!r} doesn't))r�regexrN)�
match_func�
ValueErrorr!rr7�patternr#s    r'r(z_MatchesReValidator.__call__LsZ�����u�%��'�'-�v����$�*�*�*<�*<�E�(.�(���
�
���
�&r)c�:�dj|j��S)Nz,<matches_re validator for pattern {regex!r}>)r7)r!r7r,s r'r-z_MatchesReValidator.__repr__[s"��=�D�D��*�*�E�
�	
r)N)	r.r/r0r	r7�flagsr8r(r-r1r)r'r5r5Fs!���H�E��H�E���J�
�
r)r5c� �ttdd�}|dtjtjf}||vr7t	ddjt
d�t|�D����d���tj||�}|tjur
|j}n_|tjur
|j}n@|r
|j}n1tjdj|�|�}|j}t|||�S)a}
    A validator that raises `ValueError` if the initializer is called
    with a string that doesn't match *regex*.

    :param str regex: a regex string to match against
    :param int flags: flags that will be passed to the underlying re function
        (default 0)
    :param callable func: which underlying `re` function to call (options
        are `re.fullmatch`, `re.search`, `re.match`, default
        is ``None`` which means either `re.fullmatch` or an emulation of
        it on Python 2). For performance reasons, they won't be used directly
        but on a pre-`re.compile`\ ed pattern.

    .. versionadded:: 19.2.0
    �	fullmatchNz'func' must be one of z, c3�DK�|]}|xr|jxsd���y�w)�NoneN)r.)�.0�es  r'�	<genexpr>zmatches_re.<locals>.<genexpr>xs&�����<L�q��(�a�j�j�2�F�2�<L�s� �.z(?:{})\Z)�getattr�re�search�matchr9�join�sorted�set�compiler>r!r5)r7r<�funcr>�valid_funcsr:r8s       r'rras��� ��K��.�I��d�B�I�I�r�x�x�8�K��;����	�	���<?��<L����
�	
�		
��j�j���&�G��r�x�x���]�]�
�	
����	��^�^�
�� �*�*�J��j�j��!3�!3�E�!:�E�B�G� ���J��w��z�:�:r)c�&�eZdZe�Zd�Zd�Zy)�_ProvidesValidatorc��|jj|�s>tdj|j|j|��||j|��y)rz<'{name}' must provide {interface!r} which {value!r} doesn't.)r�	interfacerN)rR�
providedByr r!rr#s    r'r(z_ProvidesValidator.__call__�sZ���~�~�(�(��/���!�6����d�n�n�E�"��������
�0r)c�:�dj|j��S)Nz0<provides validator for interface {interface!r}>�rR)r!rRr,s r'r-z_ProvidesValidator.__repr__�s"��A�H�H��n�n�I�
�	
r)N)r.r/r0r	rRr(r-r1r)r'rPrP�s����I�
�
r)rPc��t|�S)a(
    A validator that raises a `TypeError` if the initializer is called
    with an object that does not provide the requested *interface* (checks are
    performed using ``interface.providedBy(value)`` (see `zope.interface
    <https://zopeinterface.readthedocs.io/en/latest/>`_).

    :param interface: The interface to check for.
    :type interface: ``zope.interface.Interface``

    :raises TypeError: With a human readable error message, the attribute
        (of type `attr.Attribute`), the expected interface, and the
        value it got.
    )rPrUs r'rr�s���i�(�(r)c�&�eZdZe�Zd�Zd�Zy)�_OptionalValidatorc�0�|�y|j|||�y�N��	validatorr#s    r'r(z_OptionalValidator.__call__�s���=�����t�T�5�)r)c�L�djt|j���S)Nz'<optional validator for {what} or None>)�what)r!rr\r,s r'r-z_OptionalValidator.__repr__�s'��8�?�?��d�n�n�%�@�
�	
r)N)r.r/r0r	r\r(r-r1r)r'rXrX�s����I�*�
r)rXc�`�t|t�rtt|��St|�S)a�
    A validator that makes an attribute optional.  An optional attribute is one
    which can be set to ``None`` in addition to satisfying the requirements of
    the sub-validator.

    :param validator: A validator (or a list of validators) that is used for
        non-``None`` values.
    :type validator: callable or `list` of callables.

    .. versionadded:: 15.1.0
    .. versionchanged:: 17.1.0 *validator* can be a list of validators.
    )r�listrXrr[s r'rr�s)���)�T�"�!�-�	�":�;�;��i�(�(r)c�&�eZdZe�Zd�Zd�Zy)�_InValidatorc��	||jv}|s1tdj|j|j|����y#t$rd}Y�AwxYw)NFz/'{name}' must be in {options!r} (got {value!r}))r�optionsr)rdr r9r!r)r$r%r&r�
in_optionss     r'r(z_InValidator.__call__�se��	��$�,�,�.�J���A�H�H����D�L�L��I���
����	��J�	�s�A�A�Ac�:�dj|j��S)Nz(<in_ validator with options {options!r}>�rd)r!rdr,s r'r-z_InValidator.__repr__�s"��9�@�@��L�L�A�
�	
r)N)r.r/r0r	rdr(r-r1r)r'rbrb�s���h�G��
r)rbc��t|�S)a�
    A validator that raises a `ValueError` if the initializer is called
    with a value that does not belong in the options provided.  The check is
    performed using ``value in options``.

    :param options: Allowed options.
    :type options: list, tuple, `enum.Enum`, ...

    :raises ValueError: With a human readable error message, the attribute (of
       type `attr.Attribute`), the expected options, and the value it
       got.

    .. versionadded:: 17.1.0
    )rbrgs r'rr�s���� � r)c��eZdZd�Zd�Zy)�_IsCallableValidatorc��t|�s5d}t|j|j||j��|���y)rz?'{name}' must be callable (got {value!r} that is a {actual!r}).)rrr)�msgrN)�callablerr!rr")r$r%r&r�messages     r'r(z_IsCallableValidator.__call__sN�����8�
�#��N�N����%����#���	�
�r)c��y)Nz<is_callable validator>r1r,s r'r-z_IsCallableValidator.__repr__s��(r)N)r.r/r0r(r-r1r)r'rjrjs��� )r)rjc��t�S)aw
    A validator that raises a `attr.exceptions.NotCallableError` if the
    initializer is called with a value for this particular attribute
    that is not callable.

    .. versionadded:: 19.1.0

    :raises `attr.exceptions.NotCallableError`: With a human readable error
        message containing the attribute (`attr.Attribute`) name,
        and the value it got.
    )rjr1r)r'rrs
�� �!�!r)c�^�eZdZee���Zedee����Zd�Zd�Z	y)�
_DeepIterabler[N��defaultr\c�v�|j�|j|||�|D]}|j|||��y�rN)�iterable_validator�member_validator)r$r%r&r�members     r'r(z_DeepIterable.__call__/s>���"�"�.��#�#�D�$��6��F��!�!�$��f�5�r)c��|j�dndj|j��}dj||j��S)N�z
 {iterable!r})�iterablezJ<deep_iterable validator for{iterable_identifier} iterables of {member!r}>)�iterable_identifierry)rwr!rx)r$r}s  r'r-z_DeepIterable.__repr__9sV���&�&�.�
� �'�'��1H�1H�'�I�	�
(�
�&� 3��(�(��
�	
r))
r.r/r0r	rrxrrwr(r-r1r)r'rrrr(s0����
�6������� 7���6�
r)rrc��t||�S)a1
    A validator that performs deep validation of an iterable.

    :param member_validator: Validator to apply to iterable members
    :param iterable_validator: Validator to apply to iterable itself
        (optional)

    .. versionadded:: 19.1.0

    :raises TypeError: if any sub-validators fail
    )rr)rxrws  r'rrHs���)�+=�>�>r)c�z�eZdZee���Zee���Zedee����Zd�Z	d�Z
y)�_DeepMappingr[Nrsc��|j�|j|||�|D]+}|j|||�|j||||��-yrv)�mapping_validator�
key_validator�value_validator)r$r%r&r�keys     r'r(z_DeepMapping.__call__]sT���!�!�-��"�"�4��u�5��C����t�T�3�/�� � ��t�U�3�Z�8�r)c�P�dj|j|j��S)NzA<deep_mapping validator for objects mapping {key!r} to {value!r}>)r�r)r!r�r�r,s r'r-z_DeepMapping.__repr__hs%��O�
�&�T�'�'�t�/C�/C�&�
D�	Er))r.r/r0r	rr�r�rr�r(r-r1r)r'r�r�Ws9���[�]�3�M��{�}�5�O��t�x��
�7N�O��	9�Er)r�c��t|||�S)a}
    A validator that performs deep validation of a dictionary.

    :param key_validator: Validator to apply to dictionary keys
    :param value_validator: Validator to apply to dictionary values
    :param mapping_validator: Validator to apply to top-level mapping
        attribute (optional)

    .. versionadded:: 19.1.0

    :raises TypeError: if any sub-validators fail
    )r�)r�r�r�s   r'r
r
ns���
��8I�J�Jr))rNrZ)�__doc__�
__future__rrrrF�_makerrr	r
�
exceptionsr�__all__�objectrrr5rrPrrXrrbrrjrrrrr�r
r1r)r'�<module>r�ss���A�@�	�5�5�(�
���E��D�)�
�6�
�*�
�6
&� �E�$�d�+�
�&�
�,�
�4*;�Z�E��D�)�
��
�*�
�0)�"�E��D�)�
��
�*�
�)�$�E��D�)�
�6�
�*�
�,!�$�E��T�*�)�6�)�+�)�*"��E��D�)�
�F�
�*�
�>?��E��D�)�E�6�E�*�E�,
Kr)