File: //opt/alt/python35/lib/python3.5/site-packages/attr/__pycache__/validators.cpython-35.opt-1.pyc
#IGZ` � @ sQ 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
d d
� Gd d � d e � � Z d d � Z
e d
d d d
d d
� Gd d � d e � � Z d d � Z e d
d d d
d d
� Gd d � d e � � Z d d � Z e d
d d d
d d
� Gd 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�provides�reprF�slotsT�hashc @ s1 e Z d Z e � Z d d � Z d d � Z d S)�_InstanceOfValidatorc
C sU t | | j � sQ t d j d | j d | j d | j d | � | | j | � � d S)zP
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 �/validators.py�__call__ s z_InstanceOfValidator.__call__c C s d j d | j � 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 @ s1 e Z d Z e � Z d d � Z d d � Z d S)�_ProvidesValidatorc C sL | j j | � sH t d j d | j d | j d | � | | j | � � d S)zP
We use a callable class to be able to change the ``__repr__``.
z<'{name}' must provide {interface!r} which {value!r} doesn't.r � interfacer N)r% Z
providedByr r r )r r r r r r r r ? s
z_ProvidesValidator.__call__c C s d j d | j � S)Nz0<provides validator for interface {interface!r}>r% )r r% )r r r r r K s z_ProvidesValidator.__repr__N)r! r"