
    	^cn                     f   d Z ddlmZmZmZ ddlmZmZmZm	Z	 g dZ
 eddd           G d	 d
e                      Zd Z eddd           G d de                      Zd Z eddd           G d de                      Zd Z eddd           G d de                      Zd ZdS )z
Commonly useful validators.
    )absolute_importdivisionprint_function   )attr
attributesand__AndValidator)r	   in_instance_ofoptionalprovidesFT)reprslotshashc                   .    e Zd Z e            Zd Zd ZdS )_InstanceOfValidatorc                     t          || j                  s=t          d                    |j        | j        |j        |          || 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instr   r   s       F/usr/lib/python3/dist-packages/mercurial/thirdparty/attr/validators.py__call__z_InstanceOfValidator.__call__   se     %++ 	TYTY$e  = =di  	 	    c                 8    d                     | j                  S )Nz)<instance_of validator for type {type!r}>r   )r   r   r   s    r!   __repr__z_InstanceOfValidator.__repr__$   s    7VV##	
r#   N)__name__
__module____qualname__r   r   r"   r'    r#   r!   r   r      s=        466D  
 
 
 
 
r#   r   c                      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 perfomed 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%   s    r!   r   r   +   s      %%%r#   c                   .    e Zd Z e            Zd Zd ZdS )_ProvidesValidatorc                     | j                             |          s7t          d                    |j        | j         |          || j         |          dS )r   z<'{name}' must provide {interface!r} which {value!r} doesn't.)r   	interfacer   N)r0   
providedByr   r   r   r   s       r!   r"   z_ProvidesValidator.__call__?   s]     ~((// 	TY$.NNdne	  	 	r#   c                 8    d                     | j                  S )Nz0<provides validator for interface {interface!r}>r0   )r   r0   r&   s    r!   r'   z_ProvidesValidator.__repr__K   s    >VdnV--	
r#   N)r(   r)   r*   r   r0   r"   r'   r+   r#   r!   r.   r.   ;   s=        I
 
 

 
 
 
 
r#   r.   c                      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.   r3   s    r!   r   r   R   s     i(((r#   c                   .    e Zd Z e            Zd Zd ZdS )_OptionalValidatorc                 <    |d S |                      |||           d S )N	validatorr   s       r!   r"   z_OptionalValidator.__call__f   s(    =FtT5)))))r#   c                 R    d                     t          | j                            S )Nz'<optional validator for {what} or None>)what)r   r   r9   r&   s    r!   r'   z_OptionalValidator.__repr__l   s#    5Vdn--V..	
r#   N)r(   r)   r*   r   r9   r"   r'   r+   r#   r!   r6   r6   b   s=        I* * *
 
 
 
 
r#   r6   c                     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   listr6   r
   r8   s    r!   r   r   s   s:     )T"" <!-	":":;;;i(((r#   c                   .    e Zd Z e            Zd Zd ZdS )_InValidatorc                 v    || j         vr/t          d                    |j        | j         |                    d S )Nz/'{name}' must be in {options!r} (got {value!r}))r   optionsr   )rA   
ValueErrorr   r   r   s       r!   r"   z_InValidator.__call__   sC    $$ATYEJJ   %$r#   c                 8    d                     | j                  S )Nz(<in_ validator with options {options!r}>rA   )r   rA   r&   s    r!   r'   z_InValidator.__repr__   s    6VDLV))	
r#   N)r(   r)   r*   r   rA   r"   r'   r+   r#   r!   r?   r?      s=        dffG  
 
 
 
 
r#   r?   c                      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
    )r?   rD   s    r!   r   r      s        r#   N)__doc__
__future__r   r   r   _maker   r   r	   r
   __all__objectr   r   r.   r   r6   r   r?   r   r+   r#   r!   <module>rK      s    A @ @ @ @ @ @ @ @ @ 8 8 8 8 8 8 8 8 8 8 8 8   d...
 
 
 
 
6 
 
 /.
.& & &  d...
 
 
 
 
 
 
 /.
,) ) )  d...
 
 
 
 
 
 
 /.
 ) ) )$ d...
 
 
 
 
6 
 
 /.
"! ! ! ! !r#   