ó 9(Zc@`sEdZddlmZmZmZddlmZmZmZm Z ddddd gZ ed e d e d e ƒd e fd„ƒYƒZd„Zed e d e d e ƒde fd„ƒYƒZd„Zed e d e d e ƒde fd„ƒYƒZd„Zed e d e d e ƒde fd„ƒYƒZd„ZdS(s Commonly useful validators. i(tabsolute_importtdivisiontprint_functioni(tattribtattrstand_t _AndValidatorRtin_t instance_oftoptionaltprovidestreprtslotsthasht_InstanceOfValidatorcB`s#eZeƒZd„Zd„ZRS(c C`sXt||jƒsTtdjd|jd|jd|jd|ƒ||j|ƒ‚ndS(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}).tnamettypetactualtvalueN(t isinstanceRt TypeErrortformatRt __class__(tselftinsttattrR((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyt__call__s  cC`sdjd|jƒS(Ns)R(RR(R((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyt__repr__$s (t__name__t __module__RRRR(((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyRs  cC`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((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR+s t_ProvidesValidatorcB`s#eZeƒZd„Zd„ZRS(cC`sO|jj|ƒsKtdjd|jd|jd|ƒ||j|ƒ‚ndS(sP We use a callable class to be able to change the ``__repr__``. s<'{name}' must provide {interface!r} which {value!r} doesn't.Rt interfaceRN(Rt providedByRRR(RRRR((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR?s  cC`sdjd|jƒS(Ns0R(RR(R((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyRKs (RRRRRR(((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR;s  cC`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 `_). :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((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR Rs t_OptionalValidatorcB`s#eZeƒZd„Zd„ZRS(cC`s'|dkrdS|j|||ƒdS(N(tNonet validator(RRRR((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyRfs cC`sdjdt|jƒƒS(Ns'twhat(RR R#(R((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyRls (RRRR#RR(((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR!bs  cC`s)t|tƒrtt|ƒƒ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. (RtlistR!R(R#((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR ss t _InValidatorcB`s#eZeƒZd„Zd„ZRS(cC`s@||jkr<tdjd|jd|jd|ƒƒ‚ndS(Ns/'{name}' must be in {options!r} (got {value!r})RtoptionsR(R't ValueErrorRR(RRRR((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR‰s cC`sdjd|jƒS(Ns(R'(RR'(R((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyRs (RRRR'RR(((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR&…s  cC`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'((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyR—sN(t__doc__t __future__RRRt_makeRRRRt__all__tFalsetTruetobjectRRRR R!R R&R(((s./tmp/pip-build-wDUJoH/attrs/attr/validators.pyts&"