
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
U
    #IGZ`  ã                   @   sÚ   d Z ddlmZmZmZ ddlmZmZmZm	Z	 ddddd	gZ
e	d
ddd�G dd„ deƒƒZdd„ Ze	d
ddd�G dd„ deƒƒZdd	„ Ze	d
ddd�G dd„ deƒƒZdd„ Ze	d
ddd�G dd„ deƒƒZdd„ ZdS )z
Commonly useful validators.
é    )Úabsolute_importÚdivisionÚprint_functioné   )Ú_AndValidatorÚand_ÚattribÚattrsr   Úin_Úinstance_ofÚoptionalÚprovidesFT)ÚreprÚslotsÚhashc                   @   s"   e Zd Zeƒ Zdd„ Zdd„ ZdS )Ú_InstanceOfValidatorc                 C   s4   t || jƒs0tdj|j| j|j|d�|| j|ƒ‚dS )ú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Úattrr   © r   ú@/opt/alt/python38/lib/python3.8/site-packages/attr/validators.pyÚ__call__   s      ý  ûz_InstanceOfValidator.__call__c                 C   s   dj | jd�S )Nz)<instance_of validator for type {type!r}>©r   )r   r   ©r   r   r   r    Ú__repr__$   s    ÿÿz_InstanceOfValidator.__repr__N)Ú__name__Ú
__module__Ú__qualname__r   r   r!   r$   r   r   r   r    r      s   r   c                 C   s   t | ƒS )aä  
    A validator that raises a :exc:`TypeError` if the initializer is called
    with a wrong type for this particular attribute (checks are performed using
    :func:`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 :class:`attr.Attribute`), the expected type, and the value it
        got.
    )r   r"   r   r   r    r   +   s    c                   @   s"   e Zd Zeƒ Zdd„ Zdd„ ZdS )Ú_ProvidesValidatorc                 C   s0   | j  |¡s,tdj|j| j |d�|| j |ƒ‚dS )r   z<'{name}' must provide {interface!r} which {value!r} doesn't.)r   Ú	interfacer   N)r)   Z
providedByr   r   r   r   r   r   r    r!   ?   s      þ  üz_ProvidesValidator.__call__c                 C   s   dj | jd�S )Nz0<provides validator for interface {interface!r}>©r)   )r   r)   r#   r   r   r    r$   K   s    ÿÿz_ProvidesValidator.__repr__N)r%   r&   r'   r   r)   r!   r$   r   r   r   r    r(   ;   s   r(   c                 C   s   t | ƒS )a  
    A validator that raises a :exc:`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 zope.interface.Interface interface: The interface to check for.

    :raises TypeError: With a human readable error message, the attribute
        (of type :class:`attr.Attribute`), the expected interface, and the
        value it got.
    )r(   r*   r   r   r    r   R   s    c                   @   s"   e Zd Zeƒ Zdd„ Zdd„ ZdS )Ú_OptionalValidatorc                 C   s   |d krd S |   |||¡ d S )N©Ú	validatorr   r   r   r    r!   f   s    z_OptionalValidator.__call__c                 C   s   dj t| jƒd�S )Nz'<optional validator for {what} or None>)Úwhat)r   r   r-   r#   r   r   r    r$   l   s    ÿÿz_OptionalValidator.__repr__N)r%   r&   r'   r   r-   r!   r$   r   r   r   r    r+   b   s   r+   c                 C   s   t | tƒrtt| ƒƒS t| ƒ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 :class:`list` of callables.

    .. versionadded:: 15.1.0
    .. versionchanged:: 17.1.0 *validator* can be a list of validators.
    )r   Úlistr+   r   r,   r   r   r    r   s   s    
c                   @   s"   e Zd Zeƒ Zdd„ Zdd„ ZdS )Ú_InValidatorc                 C   s&   || j kr"tdj|j| j |d�ƒ‚d S )Nz/'{name}' must be in {options!r} (got {value!r}))r   Úoptionsr   )r1   Ú
ValueErrorr   r   r   r   r   r    r!   ‰   s    
  ÿÿz_InValidator.__call__c                 C   s   dj | jd�S )Nz(<in_ validator with options {options!r}>©r1   )r   r1   r#   r   r   r    r$   �   s    ÿÿz_InValidator.__repr__N)r%   r&   r'   r   r1   r!   r$   r   r   r   r    r0   …   s   r0   c                 C   s   t | ƒS )aî  
    A validator that raises a :exc:`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, :class:`enum.Enum`, ...

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

    .. versionadded:: 17.1.0
    )r0   r3   r   r   r    r
   —   s    N)Ú__doc__Ú
__future__r   r   r   Ú_maker   r   r   r	   Ú__all__Úobjectr   r   r(   r   r+   r   r0   r
   r   r   r   r    Ú<module>   s(   û	