Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/attr/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/attr/__pycache__/validators.cpython-36.pyc

3

"��cP�@s�dZddlZddlZddlmZddlmZmZddlm	Z	m
Z
mZmZddl
mZddlmZy
ejZWn"ek
r�eejd	��ZYnXd
ddd
dddddddddddddddgZdd�Zdd�Zedd
��Zed d!d!d"�Gd#d$�d$��Zd%d�Zed d!d!d&�Gd'd(�d(��ZdPd)d�Zed d!d!d"�Gd*d+�d+��Zd,d�Zed d!d!d"�Gd-d.�d.��Zd/d�Z ed d!d!d"�Gd0d1�d1��Z!d2d�Z"ed d d!d"�Gd3d4�d4��Z#d5d�Z$ed d!d!d"�Gd6d7�d7��Z%dQd8d�Z&ed d!d!d"�Gd9d:�d:��Z'dRd;d�Z(ed d!d!d&�Gd<d=�d=��Z)d>d�Z*d?d�Z+d@d�Z,dAd�Z-ed d!d!d&�GdBdC�dC��Z.dDd�Z/ed d!d!d&�GdEdF�dF��Z0dGd�Z1ed d!d!d"�GdHdI�dI��Z2dJdK�Z3ed d!d!d"�GdLdM�dM��Z4de5e6fdN�dOd�Z7dS)Sz
Commonly useful validators.
�N)�contextmanager�)�get_run_validators�set_run_validators)�
_AndValidator�and_�attrib�attrs)�default_if_none)�NotCallableError�r�
deep_iterable�deep_mapping�disabled�ge�get_disabled�gt�in_�instance_of�is_callable�le�lt�
matches_re�max_len�min_len�not_�optional�provides�set_disabledcCst|�dS)a
    Globally disable or enable running validators.

    By default, they are run.

    :param disabled: If ``True``, disable running all validators.
    :type disabled: bool

    .. warning::

        This function is not thread-safe!

    .. versionadded:: 21.3.0
    N)r)r�r�0/tmp/pip-build-_uu8ur7s/attrs/attr/validators.pyr0scCst�S)z�
    Return a bool indicating whether validators are currently disabled or not.

    :return: ``True`` if validators are currently disabled.
    :rtype: bool

    .. versionadded:: 21.3.0
    )rrrrr rBs	ccs"td�z
dVWdtd�XdS)z�
    Context manager that disables running validators within its context.

    .. warning::

        This context manager is not thread-safe!

    .. versionadded:: 21.3.0
    FNT)rrrrr rNs
FT)�repr�slots�hashc@s"eZdZe�Zdd�Zdd�ZdS)�_InstanceOfValidatorcCs4t||j�s0tdj|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}).)�name�type�actual�valueN)�
isinstancer&�	TypeError�formatr%�	__class__)�self�inst�attrr(rrr �__call__dsz_InstanceOfValidator.__call__cCsdj|jd�S)Nz)<instance_of validator for type {type!r}>)r&)r+r&)r-rrr �__repr__vsz_InstanceOfValidator.__repr__N)�__name__�
__module__�__qualname__rr&r0r1rrrr r$`sr$cCst|�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 type

    :raises TypeError: With a human readable error message, the attribute
        (of type `attrs.Attribute`), the expected type, and the value it
        got.
    )r$)r&rrr r|s
)r!�frozenr"c@s(eZdZe�Ze�Zdd�Zdd�ZdS)�_MatchesReValidatorcCs0|j|�s,tdj|j|jj|d�||j|��dS)zP
        We use a callable class to be able to change the ``__repr__``.
        z9'{name}' must match regex {pattern!r} ({value!r} doesn't))r%�patternr(N)�
match_func�
ValueErrorr+r%r7)r-r.r/r(rrr r0�s
z_MatchesReValidator.__call__cCsdj|jd�S)Nz.<matches_re validator for pattern {pattern!r}>)r7)r+r7)r-rrr r1�sz_MatchesReValidator.__repr__N)r2r3r4rr7r8r0r1rrrr r6�sr6cCs�tjdtjtjf}||kr@tdjdjtdd�t|�D������t	|t
�r\|rVtd��|}ntj||�}|tjkrz|j}n|tjkr�|j}n|j}t
||�S)a�
    A validator that raises `ValueError` if the initializer is called
    with a string that doesn't match *regex*.

    :param regex: a regex string or precompiled pattern 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. Valid options
        are `re.fullmatch`, `re.search`, and `re.match`; the default ``None``
        means `re.fullmatch`. For performance reasons, the pattern is always
        precompiled using `re.compile`.

    .. versionadded:: 19.2.0
    .. versionchanged:: 21.3.0 *regex* can be a pre-compiled pattern.
    Nz'func' must be one of {}.z, css|]}|r|jpdVqdS)�NoneN)r2)�.0�errr �	<genexpr>�szmatches_re.<locals>.<genexpr>zR'flags' can only be used with a string pattern; pass flags to re.compile() instead)�re�	fullmatch�search�matchr9r+�join�sorted�setr)�Patternr*�compiler6)�regex�flags�funcZvalid_funcsr7r8rrr r�s&


c@s"eZdZe�Zdd�Zdd�ZdS)�_ProvidesValidatorcCs0|jj|�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%�	interfacer(N)rKZ
providedByr*r+r%)r-r.r/r(rrr r0�sz_ProvidesValidator.__call__cCsdj|jd�S)Nz0<provides validator for interface {interface!r}>)rK)r+rK)r-rrr r1�sz_ProvidesValidator.__repr__N)r2r3r4rrKr0r1rrrr rJ�srJcCst|�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 `attrs.Attribute`), the expected interface, and the
        value it got.
    )rJ)rKrrr r�sc@s"eZdZe�Zdd�Zdd�ZdS)�_OptionalValidatorcCs|dkrdS|j|||�dS)N)�	validator)r-r.r/r(rrr r0sz_OptionalValidator.__call__cCsdjt|j�d�S)Nz'<optional validator for {what} or None>)�what)r+r!rM)r-rrr r1
sz_OptionalValidator.__repr__N)r2r3r4rrMr0r1rrrr rLsrLcCst|t�rtt|��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.
    )r)�listrLr)rMrrr rs
c@s"eZdZe�Zdd�Zdd�ZdS)�_InValidatorcCsPy||jk}Wntk
r&d}YnX|sLtdj|j|j|d�||j|��dS)NFz/'{name}' must be in {options!r} (got {value!r}))r%�optionsr()rQr*r9r+r%)r-r.r/r(Z
in_optionsrrr r0&s
z_InValidator.__call__cCsdj|jd�S)Nz(<in_ validator with options {options!r}>)rQ)r+rQ)r-rrr r16sz_InValidator.__repr__N)r2r3r4rrQr0r1rrrr rP"srPcCst|�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 `attrs.Attribute`), the expected options, and the value it
       got.

    .. versionadded:: 17.1.0
    .. versionchanged:: 22.1.0
       The ValueError was incomplete until now and only contained the human
       readable error message. Now it contains all the information that has
       been promised since 17.1.0.
    )rP)rQrrr r<sc@seZdZdd�Zdd�ZdS)�_IsCallableValidatorcCs,t|�s(d}t|j|j||jd�|d��dS)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}).)r%r(r')�msgr(N)�callablerr+r%r,)r-r.r/r(�messagerrr r0Tsz_IsCallableValidator.__call__cCsdS)Nz<is_callable validator>r)r-rrr r1dsz_IsCallableValidator.__repr__N)r2r3r4r0r1rrrr rRRsrRcCst�S)ax
    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 (`attrs.Attribute`) name,
        and the value it got.
    )rRrrrr rhsc@s:eZdZee�d�Zedee��d�Zdd�Zdd�Z	dS)�
_DeepIterable)rMN)�defaultrMcCs8|jdk	r|j|||�x|D]}|j|||�qWdS)zP
        We use a callable class to be able to change the ``__repr__``.
        N)�iterable_validator�member_validator)r-r.r/r(�memberrrr r0~s

z_DeepIterable.__call__cCs*|jdkrdn
d|j��}dj||jd�S)Nr� zJ<deep_iterable validator for{iterable_identifier} iterables of {member!r}>)�iterable_identifierrZ)rXr+rY)r-r\rrr r1�s
z_DeepIterable.__repr__)
r2r3r4rrrYrrXr0r1rrrr rVws

rVcCs t|ttf�rt|�}t||�S)a4
    A validator that performs deep validation of an iterable.

    :param member_validator: Validator(s) 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
    )r)rO�tuplerrV)rYrXrrr r
�sc@sFeZdZee�d�Zee�d�Zedee��d�Zdd�Z	dd�Z
dS)�_DeepMapping)rMN)rWrMcCsJ|jdk	r|j|||�x,|D]$}|j|||�|j||||�qWdS)zP
        We use a callable class to be able to change the ``__repr__``.
        N)�mapping_validator�
key_validator�value_validator)r-r.r/r(�keyrrr r0�s


z_DeepMapping.__call__cCsdj|j|jd�S)NzA<deep_mapping validator for objects mapping {key!r} to {value!r}>)rbr()r+r`ra)r-rrr r1�sz_DeepMapping.__repr__)r2r3r4rrr`rarr_r0r1rrrr r^�s
r^cCs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
    )r^)r`rar_rrr r�s
c@s.eZdZe�Ze�Ze�Zdd�Zdd�ZdS)�_NumberValidatorcCs.|j||j�s*tdj|j|j|j|d���dS)zP
        We use a callable class to be able to change the ``__repr__``.
        z&'{name}' must be {op} {bound}: {value})r%�op�boundr(N)�compare_funcrer9r+r%�
compare_op)r-r.r/r(rrr r0�sz_NumberValidator.__call__cCsdj|j|jd�S)Nz<Validator for x {op} {bound}>)rdre)r+rgre)r-rrr r1�sz_NumberValidator.__repr__N)	r2r3r4rrergrfr0r1rrrr rc�s
rccCst|dtj�S)z�
    A validator that raises `ValueError` if the initializer is called
    with a number larger or equal to *val*.

    :param val: Exclusive upper bound for values

    .. versionadded:: 21.3.0
    �<)rc�operatorr)�valrrr r�s	cCst|dtj�S)z�
    A validator that raises `ValueError` if the initializer is called
    with a number greater than *val*.

    :param val: Inclusive upper bound for values

    .. versionadded:: 21.3.0
    z<=)rcrir)rjrrr r�s	cCst|dtj�S)z�
    A validator that raises `ValueError` if the initializer is called
    with a number smaller than *val*.

    :param val: Inclusive lower bound for values

    .. versionadded:: 21.3.0
    z>=)rcrir)rjrrr rs	cCst|dtj�S)z�
    A validator that raises `ValueError` if the initializer is called
    with a number smaller or equal to *val*.

    :param val: Exclusive lower bound for values

    .. versionadded:: 21.3.0
    �>)rcrir)rjrrr r
s	c@s"eZdZe�Zdd�Zdd�ZdS)�_MaxLengthValidatorcCs.t|�|jkr*tdj|j|jt|�d���dS)zP
        We use a callable class to be able to change the ``__repr__``.
        z*Length of '{name}' must be <= {max}: {len})r%�max�lenN)rn�
max_lengthr9r+r%)r-r.r/r(rrr r0sz_MaxLengthValidator.__call__cCsd|j�d�S)Nz<max_len validator for rk)ro)r-rrr r1(sz_MaxLengthValidator.__repr__N)r2r3r4rror0r1rrrr rlsrlcCst|�S)z�
    A validator that raises `ValueError` if the initializer is called
    with a string or iterable that is longer than *length*.

    :param int length: Maximum length of the string or iterable

    .. versionadded:: 21.3.0
    )rl)�lengthrrr r,s	c@s"eZdZe�Zdd�Zdd�ZdS)�_MinLengthValidatorcCs.t|�|jkr*tdj|j|jt|�d���dS)zP
        We use a callable class to be able to change the ``__repr__``.
        z*Length of '{name}' must be => {min}: {len})r%�minrnN)rn�
min_lengthr9r+r%)r-r.r/r(rrr r0<sz_MinLengthValidator.__call__cCsd|j�d�S)Nz<min_len validator for rk)rs)r-rrr r1Gsz_MinLengthValidator.__repr__N)r2r3r4rrsr0r1rrrr rq8srqcCst|�S)z�
    A validator that raises `ValueError` if the initializer is called
    with a string or iterable that is shorter than *length*.

    :param int length: Minimum length of the string or iterable

    .. versionadded:: 22.1.0
    )rq)rprrr rKs	c@s"eZdZe�Zdd�Zdd�ZdS)�_SubclassOfValidatorcCs0t||j�s,tdj|j|j|d�||j|��dS)zP
        We use a callable class to be able to change the ``__repr__``.
        z8'{name}' must be a subclass of {type!r} (got {value!r}).)r%r&r(N)�
issubclassr&r*r+r%)r-r.r/r(rrr r0[sz_SubclassOfValidator.__call__cCsdj|jd�S)Nz)<subclass_of validator for type {type!r}>)r&)r+r&)r-rrr r1lsz_SubclassOfValidator.__repr__N)r2r3r4rr&r0r1rrrr rtWsrtcCst|�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
    `issubclass` 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 `attrs.Attribute`), the expected type, and the value it
        got.
    )rt)r&rrr �_subclass_ofrs
rvc@sJeZdZe�Zeed�d�Zeeee	�e
e�d�d�Zdd�Z
dd�Zd	S)
�
_NotValidatorzCnot_ validator child '{validator!r}' did not raise a captured error)�	converter)rYrX)rMcCsRy|j|||�Wn|jk
r(Yn&Xt|jj|j|jd�||j||j��dS)N)rM�	exc_types)rMryr9rSr+)r-r.r/r(rrr r0�sz_NotValidator.__call__cCsdj|j|jd�S)Nz;<not_ validator wrapping {what!r}, capturing {exc_types!r}>)rNry)r+rMry)r-rrr r1�sz_NotValidator.__repr__N)r2r3r4rrMr
rSr
rv�	Exceptionrr]ryr0r1rrrr rw�s
rw)rSrycCs4yt|�}Wntk
r&|f}YnXt|||�S)a

    A validator that wraps and logically 'inverts' the validator passed to it.
    It will raise a `ValueError` if the provided validator *doesn't* raise a
    `ValueError` or `TypeError` (by default), and will suppress the exception
    if the provided validator *does*.

    Intended to be used with existing validators to compose logic without
    needing to create inverted variants, for example, ``not_(in_(...))``.

    :param validator: A validator to be logically inverted.
    :param msg: Message to raise if validator fails.
        Formatted with keys ``exc_types`` and ``validator``.
    :type msg: str
    :param exc_types: Exception type(s) to capture.
        Other types raised by child validators will not be intercepted and
        pass through.

    :raises ValueError: With a human readable error message,
        the attribute (of type `attrs.Attribute`),
        the validator that failed to raise an exception,
        the value it got,
        and the expected exception types.

    .. versionadded:: 22.2.0
    )r]r*rw)rMrSryrrr r�s
)rN)N)N)8�__doc__rir>�
contextlibrZ_configrr�_makerrrr	�
convertersr
�
exceptionsrrE�AttributeErrorr&rF�__all__rrrr$rr6rrJrrLrrPrrRrrVr
r^rrcrrrrrlrrqrrtrvrwr9r*rrrrr �<module>s|

0 

*

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists