ó
i€
\c           @` sE  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
 e d e d e ƒ d e f d „  ƒ  Yƒ Z d „  Z e	 d
 e d e d e ƒ d e f d „  ƒ  Yƒ Z d „  Z e	 d
 e d e d e ƒ d e f d „  ƒ  Yƒ Z d „  Z e	 d
 e d e d e ƒ d e f d „  ƒ  Yƒ Z d „  Z d S(   s   
Commonly useful validators.
i    (   t   absolute_importt   divisiont   print_functioni   (   t   _AndValidatort   and_t   attribt   attrsR   t   in_t   instance_oft   optionalt   providest   reprt   slotst   hasht   _InstanceOfValidatorc           B` s#   e  Z e ƒ  Z d  „  Z d „  Z RS(   c      
   C` sX   t  | |  j ƒ sT t d j d | j d |  j d | j d | ƒ | |  j | ƒ ‚ n  d S(   sP   
        We use a callable class to be able to change the ``__repr__``.
        s?   '{name}' must be {type!r} (got {value!r} that is a {actual!r}).t   namet   typet   actualt   valueN(   t
   isinstanceR   t	   TypeErrort   formatR   t	   __class__(   t   selft   instt   attrR   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyt   __call__   s    				c         C` s   d j  d |  j ƒ S(   Ns)   <instance_of validator for type {type!r}>R   (   R   R   (   R   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyt   __repr__#   s    	(   t   __name__t
   __module__R   R   R   R   (    (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR      s   		c         C` s
   t  |  ƒ S(   sä  
    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   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   )   s    t   _ProvidesValidatorc           B` s#   e  Z e ƒ  Z d  „  Z d „  Z RS(   c         C` sO   |  j  j | ƒ sK t d j d | j d |  j  d | ƒ | |  j  | ƒ ‚ n  d S(   sP   
        We use a callable class to be able to change the ``__repr__``.
        s<   '{name}' must provide {interface!r} which {value!r} doesn't.R   t	   interfaceR   N(   R   t
   providedByR   R   R   (   R   R   R   R   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   =   s    	c         C` s   d j  d |  j ƒ S(   Ns0   <provides validator for interface {interface!r}>R   (   R   R   (   R   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   L   s    	(   R   R   R   R   R   R   (    (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   9   s   		c         C` s
   t  |  ƒ S(   s  
    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   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR
   R   s    t   _OptionalValidatorc           B` s#   e  Z e ƒ  Z d  „  Z d „  Z RS(   c         C` s'   | d  k r d  S|  j | | | ƒ d  S(   N(   t   Nonet	   validator(   R   R   R   R   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   f   s    c         C` s   d j  d t |  j ƒ ƒ S(   Ns'   <optional validator for {what} or None>t   what(   R   R   R#   (   R   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   l   s    	(   R   R   R   R#   R   R   (    (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR!   b   s   		c         C` s)   t  |  t ƒ r t t |  ƒ ƒ St |  ƒ S(   sÉ  
    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   t   listR!   R   (   R#   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR	   r   s    t   _InValidatorc           B` s#   e  Z e ƒ  Z d  „  Z d „  Z RS(   c         C` sf   y | |  j  k } Wn t k
 r. } t } n X| sb t d j d | j d |  j  d | ƒ ƒ ‚ n  d  S(   Ns/   '{name}' must be in {options!r} (got {value!r})R   t   optionsR   (   R'   R   t   Falset
   ValueErrorR   R   (   R   R   R   R   t
   in_optionst   e(    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   ˆ   s    
	c         C` s   d j  d |  j ƒ S(   Ns(   <in_ validator with options {options!r}>R'   (   R   R'   (   R   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   •   s    	(   R   R   R   R'   R   R   (    (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR&   „   s   		c         C` s
   t  |  ƒ S(   sî  
    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&   (   R'   (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyR   ›   s    N(   t   __doc__t
   __future__R    R   R   t   _makeR   R   R   R   t   __all__R(   t   Truet   objectR   R   R   R
   R!   R	   R&   R   (    (    (    sD   /data/av2000/b2b/venv/lib/python2.7/site-packages/attr/validators.pyt   <module>   s   "			