File "validators.cpython-37.pyc"

Full Path: /home/attunedd/public_html/byp/izo/con7ext_sym404/rintoar.txt/opt/alt/python37/lib/python3.7/site-packages/attr/__pycache__/validators.cpython-37.pyc
File size: 11.37 KB
MIME-type: text/x-bytecode.python
Charset: 8 bit

B

^u_,	@sdZddlmZmZmZddlZddlmZmZm	Z	m
Z
ddlmZddd	d
ddd
ddg	Z
e
ddddGdddeZddZe
ddddGdddeZd,dd
Ze
ddddGdddeZddZe
ddddGdddeZddZe
ddddGd d!d!eZd"d
Ze
ddddGd#d$d$eZd%dZe
ddddGd&d'd'eZd-d(dZe
ddddGd)d*d*eZd.d+d	ZdS)/z
Commonly useful validators.
)absolute_importdivisionprint_functionN)
_AndValidatorand_attribattrs)NotCallableErrorr
deep_iterabledeep_mappingin_instance_ofis_callable
matches_reoptionalprovidesFT)reprslotshashc@s"eZdZeZddZddZdS)_InstanceOfValidatorcCs4t||js0tdj|j|j|j|d||j|dS)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}).)nametypeactualvalueN)
isinstancer	TypeErrorformatr	__class__)selfinstattrrr"@/opt/alt/python37/lib/python3.7/site-packages/attr/validators.py__call__sz_InstanceOfValidator.__call__cCsdj|jdS)Nz)<instance_of validator for type {type!r}>)r)rr)rr"r"r#__repr__0sz_InstanceOfValidator.__repr__N)__name__
__module____qualname__rrr$r%r"r"r"r#rsrcCst|S)a
    A validator that raises a `TypeError` if the initializer is called
    with a wrong type for this particular attribute (checks are performed using
    `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 `attr.Attribute`), the expected type, and the value it
        got.
    )r)rr"r"r#r6s
)rfrozenrc@s.eZdZeZeZeZddZddZdS)_MatchesReValidatorcCs0||s,tdj|j|jj|d||j|dS)zP
        We use a callable class to be able to change the ``__repr__``.
        z7'{name}' must match regex {regex!r} ({value!r} doesn't))rregexrN)
match_func
ValueErrorrrr+pattern)rr r!rr"r"r#r$Ls
z_MatchesReValidator.__call__cCsdj|jdS)Nz,<matches_re validator for pattern {regex!r}>)r+)rr+)rr"r"r#r%[sz_MatchesReValidator.__repr__N)	r&r'r(rr+flagsr,r$r%r"r"r"r#r*Fs
r*cCsttdd}|dtjtjf}||krJtddtddt|Dft||}|tjkrh|j}n6|tjkrz|j}n$|r|j	}ntd
||}|j}t|||S)a}
    A validator that raises `ValueError` if the initializer is called
    with a string that doesn't match *regex*.

    :param str regex: a regex string to match against
    :param int flags: flags that will be passed to the underlying re function
        (default 0)
    :param callable func: which underlying `re` function to call (options
        are `re.fullmatch`, `re.search`, `re.match`, default
        is ``None`` which means either `re.fullmatch` or an emulation of
        it on Python 2). For performance reasons, they won't be used directly
        but on a pre-`re.compile`\ ed pattern.

    .. versionadded:: 19.2.0
    	fullmatchNz'func' must be one of %s.z, css|]}|r|jpdVqdS)NoneN)r&).0er"r"r#	<genexpr>yszmatches_re.<locals>.<genexpr>z(?:{})\Z)getattrresearchmatchr-joinsortedsetcompiler0rr*)r+r/funcr0Zvalid_funcsr.r,r"r"r#ras$

c@s"eZdZeZddZddZdS)_ProvidesValidatorcCs0|j|s,tdj|j|j|d||j|dS)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	interfacerN)r?Z
providedByrrr)rr r!rr"r"r#r$sz_ProvidesValidator.__call__cCsdj|jdS)Nz0<provides validator for interface {interface!r}>)r?)rr?)rr"r"r#r%sz_ProvidesValidator.__repr__N)r&r'r(rr?r$r%r"r"r"r#r>sr>cCst|S)a(
    A validator that raises a `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 interface: The interface to check for.
    :type interface: ``zope.interface.Interface``

    :raises TypeError: With a human readable error message, the attribute
        (of type `attr.Attribute`), the expected interface, and the
        value it got.
    )r>)r?r"r"r#rsc@s"eZdZeZddZddZdS)_OptionalValidatorcCs|dkrdS||||dS)N)	validator)rr r!rr"r"r#r$sz_OptionalValidator.__call__cCsdjt|jdS)Nz'<optional validator for {what} or None>)what)rrrA)rr"r"r#r%sz_OptionalValidator.__repr__N)r&r'r(rrAr$r%r"r"r"r#r@sr@cCst|trtt|St|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 `list` of callables.

    .. versionadded:: 15.1.0
    .. versionchanged:: 17.1.0 *validator* can be a list of validators.
    )rlistr@r)rAr"r"r#rs
c@s"eZdZeZddZddZdS)_InValidatorcCsHy||jk}Wntk
r&d}YnX|sDtdj|j|j|ddS)NFz/'{name}' must be in {options!r} (got {value!r}))roptionsr)rErr-rr)rr r!rZ
in_optionsr"r"r#r$s
z_InValidator.__call__cCsdj|jdS)Nz(<in_ validator with options {options!r}>)rE)rrE)rr"r"r#r%sz_InValidator.__repr__N)r&r'r(rrEr$r%r"r"r"r#rDs
rDcCst|S)a
    A validator that raises a `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, `enum.Enum`, ...

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

    .. versionadded:: 17.1.0
    )rD)rEr"r"r#r
sc@seZdZddZddZdS)_IsCallableValidatorcCs,t|s(d}t|j|j||jd|ddS)zP
        We use a callable class to be able to change the ``__repr__``.
        z?'{name}' must be callable (got {value!r} that is a {actual!r}).)rrr)msgrN)callabler
rrr)rr r!rmessager"r"r#r$sz_IsCallableValidator.__call__cCsdS)Nz<is_callable validator>r")rr"r"r#r%sz_IsCallableValidator.__repr__N)r&r'r(r$r%r"r"r"r#rFsrFcCstS)aw
    A validator that raises a `attr.exceptions.NotCallableError` if the
    initializer is called with a value for this particular attribute
    that is not callable.

    .. versionadded:: 19.1.0

    :raises `attr.exceptions.NotCallableError`: With a human readable error
        message containing the attribute (`attr.Attribute`) name,
        and the value it got.
    )rFr"r"r"r#rsc@s:eZdZeedZedeedZddZddZ	dS)
_DeepIterable)rAN)defaultrAcCs8|jdk	r||||x|D]}||||qWdS)zP
        We use a callable class to be able to change the ``__repr__``.
        N)iterable_validatormember_validator)rr r!rmemberr"r"r#r$/s

z_DeepIterable.__call__cCs,|jdkrdndj|jd}dj||jdS)Nz
 {iterable!r})iterablezJ<deep_iterable validator for{iterable_identifier} iterables of {member!r}>)iterable_identifierrN)rLrrM)rrQr"r"r#r%9s
z_DeepIterable.__repr__)
r&r'r(rrrMrrLr$r%r"r"r"r#rJ(s

rJcCs
t||S)a1
    A validator that performs deep validation of an iterable.

    :param member_validator: Validator to apply to iterable members
    :param iterable_validator: Validator to apply to iterable itself
        (optional)

    .. versionadded:: 19.1.0

    :raises TypeError: if any sub-validators fail
    )rJ)rMrLr"r"r#rHsc@sFeZdZeedZeedZedeedZddZ	ddZ
dS)_DeepMapping)rAN)rKrAcCsJ|jdk	r||||x,|D]$}|||||||||qWdS)zP
        We use a callable class to be able to change the ``__repr__``.
        N)mapping_validator
key_validatorvalue_validator)rr r!rkeyr"r"r#r$]s


z_DeepMapping.__call__cCsdj|j|jdS)NzA<deep_mapping validator for objects mapping {key!r} to {value!r}>)rVr)rrTrU)rr"r"r#r%hsz_DeepMapping.__repr__)r&r'r(rrrTrUrrSr$r%r"r"r"r#rRWs
rRcCst|||S)a}
    A validator that performs deep validation of a dictionary.

    :param key_validator: Validator to apply to dictionary keys
    :param value_validator: Validator to apply to dictionary values
    :param mapping_validator: Validator to apply to top-level mapping
        attribute (optional)

    .. versionadded:: 19.1.0

    :raises TypeError: if any sub-validators fail
    )rR)rTrUrSr"r"r#rns
)rN)N)N)__doc__
__future__rrrr6_makerrrr	
exceptionsr
__all__objectrrr*rr>rr@rrDr
rFrrJrrRrr"r"r"r#<module>sJ
-