CasperSecurity

Current Path : /lib/python3/dist-packages/attr/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/attr/__pycache__/validators.cpython-310.pyc

o

��`�,�@s�dZddlmZmZmZddlZddlmZmZm	Z	m
Z
ddlmZgd�Z
e
dd	d	d
�Gdd�de��Zd
d�Ze
dd	d	d�Gdd�de��Zd,dd�Ze
dd	d	d
�Gdd�de��Zdd�Ze
dd	d	d
�Gdd�de��Zdd�Ze
dd	d	d
�Gdd�de��Zdd�Ze
ddd	d
�Gd d!�d!e��Zd"d#�Ze
dd	d	d
�Gd$d%�d%e��Zd-d&d'�Ze
dd	d	d
�Gd(d)�d)e��Zd-d*d+�ZdS).z
Commonly useful validators.
�)�absolute_import�division�print_functionN�)�
_AndValidator�and_�attrib�attrs)�NotCallableError)	r�
deep_iterable�deep_mapping�in_�instance_of�is_callable�
matches_re�optional�providesFT)�repr�slots�hashc@�"eZdZe�Zdd�Zdd�ZdS)�_InstanceOfValidatorcCs4t||j�stdj|j|j|j|d�||j|��dS)�P
        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%�1/usr/lib/python3/dist-packages/attr/validators.py�__call__s���z_InstanceOfValidator.__call__cC�dj|jd�S)Nz)<instance_of validator for type {type!r}>�r)rr�r"r%r%r&�__repr__0��z_InstanceOfValidator.__repr__N)�__name__�
__module__�__qualname__rrr'r+r%r%r%r&rsrcC�t|�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.
    )rr)r%r%r&r6s
r)r�frozenrc@s.eZdZe�Ze�Ze�Zdd�Zdd�ZdS)�_MatchesReValidatorcCs0|�|�stdj|j|jj|d�||j|��dS)rz7'{name}' must match regex {regex!r} ({value!r} doesn't))r�regexrN)�
match_func�
ValueErrorrrr3�patternr!r%r%r&r'Ls
���z_MatchesReValidator.__call__cCr()Nz,<matches_re validator for pattern {regex!r}>)r3)rr3r*r%r%r&r+[r,z_MatchesReValidator.__repr__N)	r-r.r/rr3�flagsr4r'r+r%r%r%r&r2Fsr2cCs�ttdd�}|dtjtjf}||vr%tdd�tdd�t|�D���f��t�||�}|tjur4|j}n|tjur=|j}n|rC|j	}nt�d�
|�|�}|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	|jp
dVqdS)�NoneN)r-)�.0�er%r%r&�	<genexpr>xs�
�zmatches_re.<locals>.<genexpr>z(?:{})\Z)�getattr�re�search�matchr5�join�sorted�set�compiler8rr2)r3r7�funcr8�valid_funcsr6r4r%r%r&ras.�����

rc@r)�_ProvidesValidatorcCs0|j�|�stdj|j|j|d�||j|��dS)rz<'{name}' must provide {interface!r} which {value!r} doesn't.)r�	interfacerN)rH�
providedByrrrr!r%r%r&r'�s
���z_ProvidesValidator.__call__cCr()Nz0<provides validator for interface {interface!r}>�rH)rrHr*r%r%r&r+�r,z_ProvidesValidator.__repr__N)r-r.r/rrHr'r+r%r%r%r&rG�srGcCr0)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.
    )rGrJr%r%r&r�src@r)�_OptionalValidatorcCs|durdS|�|||�dS�N��	validatorr!r%r%r&r'�sz_OptionalValidator.__call__cCsdjt|j�d�S)Nz'<optional validator for {what} or None>)�what)rrrNr*r%r%r&r+�s�z_OptionalValidator.__repr__N)r-r.r/rrNr'r+r%r%r%r&rK�srKcCst|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�listrKrrMr%r%r&r�s

rc@r)�_InValidatorcCsFz||jv}Wntyd}Ynw|s!tdj|j|j|d���dS)NFz/'{name}' must be in {options!r} (got {value!r}))r�optionsr)rRrr5rr)r"r#r$r�
in_optionsr%r%r&r'�s�
���z_InValidator.__call__cCr()Nz(<in_ validator with options {options!r}>�rR)rrRr*r%r%r&r+�r,z_InValidator.__repr__N)r-r.r/rrRr'r+r%r%r%r&rQ�s
rQcCr0)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
    )rQrTr%r%r&r
�sr
c@seZdZdd�Zdd�ZdS)�_IsCallableValidatorcCs,t|�sd}t|j|j||jd�|d��dS)rz?'{name}' must be callable (got {value!r} that is a {actual!r}).)rrr)�msgrN)�callabler
rrr )r"r#r$r�messager%r%r&r's�
���z_IsCallableValidator.__call__cCsdS)Nz<is_callable validator>r%r*r%r%r&r+sz_IsCallableValidator.__repr__N)r-r.r/r'r+r%r%r%r&rUsrUcCst�S)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.
    )rUr%r%r%r&rsrc@s:eZdZee�d�Zedee��d�Zdd�Zdd�Z	dS)�
_DeepIterablerMN��defaultrNcCs4|jdur|�|||�|D]	}|�|||�qdS�rN)�iterable_validator�member_validator)r"r#r$r�memberr%r%r&r'/s

�z_DeepIterable.__call__cCs,|jdurdndj|jd�}dj||jd�S)N�z
 {iterable!r})�iterablezJ<deep_iterable validator for{iterable_identifier} iterables of {member!r}>)�iterable_identifierr_)r]rr^)r"rbr%r%r&r+9s
���z_DeepIterable.__repr__)
r-r.r/rrr^rr]r'r+r%r%r%r&rY(s
�
rYcCs
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
    )rY)r^r]r%r%r&rHs
rc@sFeZdZee�d�Zee�d�Zedee��d�Zdd�Z	dd�Z
dS)�_DeepMappingrMNrZcCsF|jdur|�|||�|D]}|�|||�|�||||�qdSr\)�mapping_validator�
key_validator�value_validator)r"r#r$r�keyr%r%r&r']s
�z_DeepMapping.__call__cCsdj|j|jd�S)NzA<deep_mapping validator for objects mapping {key!r} to {value!r}>)rgr)rrerfr*r%r%r&r+hs
�z_DeepMapping.__repr__)r-r.r/rrrerfrrdr'r+r%r%r%r&rcWsrccCs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
    )rc)rerfrdr%r%r&rns
r)rNrL)�__doc__�
__future__rrrr>�_makerrrr	�
exceptionsr
�__all__�objectrrr2rrGrrKrrQr
rUrrYrrcrr%r%r%r&�<module>s<

-

Hacker Blog, Shell İndir, Sql İnjection, XSS Attacks, LFI Attacks, Social Hacking, Exploit Bot, Proxy Tools, Web Shell, PHP Shell, Alfa Shell İndir, Hacking Training Set, DDoS Script, Denial Of Service, Botnet, RFI Attacks, Encryption
Telegram @BIBIL_0DAY