
    ,hNN                     v   d Z ddlZddlZddlmZ ddlmZ ddlmZmZ ddl	m
Z
mZmZmZ ddlmZ dd	lmZ g d
Zd Zd Zed        Z eddd       G d d             Zd Z eddd       G d d             Zd=dZ eddd       G d d             Zd Z eddd       G d d             Zd Z eddd       G d d             Zd  Z eddd       G d! d"             Z d>d#Z! eddd       G d$ d%             Z"d>d&Z# eddd       G d' d(             Z$d) Z%d* Z&d+ Z'd, Z( eddd       G d- d.             Z)d/ Z* eddd       G d0 d1             Z+d2 Z, eddd       G d3 d4             Z-d5 Z. eddd       G d6 d7             Z/de0e1fd8d9Z2 eddd       G d: d;             Z3d< Z4y)?z
Commonly useful validators.
    N)contextmanager)Pattern   )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or_set_disabledc                     t        |         y)a  
    Globally disable or enable running validators.

    By default, they are run.

    Args:
        disabled (bool): If `True`, disable running all validators.

    .. warning::

        This function is not thread-safe!

    .. versionadded:: 21.3.0
    Nr   )r   s    Q/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/attr/validators.pyr   r   *   s     8|$    c                      t                S )z
    Return a bool indicating whether validators are currently disabled or not.

    Returns:
        bool:`True` if validators are currently disabled.

    .. versionadded:: 21.3.0
    )r    r#   r"   r   r   <   s     "###r#   c               #   b   K   t        d       	 d t        d       y# t        d       w xY ww)z
    Context manager that disables running validators within its context.

    .. warning::

        This context manager is not thread-safe!

    .. versionadded:: 21.3.0
    FNTr!   r%   r#   r"   r   r   H   s)      u!4 4 s   / /,/FT)reprslotsunsafe_hashc                   &    e Zd Z e       Zd Zd Zy)_InstanceOfValidatorc           	          t        || j                        sEd|j                   d| j                  d|d|j                  d	}t	        ||| j                  |      y)P
        We use a callable class to be able to change the ``__repr__``.
        '
' must be  (got z that is a ).N)
isinstancetypename	__class__	TypeErrorselfinstattrvaluemsgs        r"   __call__z_InstanceOfValidator.__call__^   se     %+dii[
499-veYkRWRaRaQddfgC			  ,r#   c                 "    d| j                   dS )Nz <instance_of validator for type >r3   r8   s    r"   __repr__z_InstanceOfValidator.__repr__k       1$))a@@r#   N__name__
__module____qualname__r
   r3   r=   rB   r%   r#   r"   r+   r+   Z       8DAr#   r+   c                     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).

    Args:
        type (type | tuple[type]): The type to check for.

    Raises:
        TypeError:
            With a human readable error message, the attribute (of type
            `attrs.Attribute`), the expected type, and the value it got.
    )r+   r@   s    r"   r   r   o         %%r#   )r'   frozenr(   c                   4    e Zd Z e       Z e       Zd Zd Zy)_MatchesReValidatorc                     | j                  |      sBd|j                   d| j                  j                  d|d}t        ||| j                  |      y)r-   r.   z' must match regex z (z	 doesn't)N)
match_funcr4   pattern
ValueErrorr7   s        r"   r=   z_MatchesReValidator.__call__   s]     u%dii[ 3DLL4H4H3K2eYV_`C	  &r#   c                 "    d| j                   dS )Nz"<matches_re validator for pattern r?   )rP   rA   s    r"   rB   z_MatchesReValidator.__repr__   s    3DLL3C1EEr#   N)rE   rF   rG   r
   rP   rO   r=   rB   r%   r#   r"   rM   rM      s    hGJFr#   rM   c           
         t         j                  dt         j                  t         j                  f}||vrDdj	                  dj                  t        d t        |      D                          }t        |      t        | t              r|rd}t        |      | }nt        j                  | |      }|t         j                  u r|j                  }n+|t         j                  u r|j                  }n|j                  }t        ||      S )a  
    A validator that raises `ValueError` if the initializer is called with a
    string that doesn't match *regex*.

    Args:
        regex (str, re.Pattern):
            A regex string or precompiled pattern to match against

        flags (int):
            Flags that will be passed to the underlying re function (default 0)

        func (typing.Callable):
            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, c              3   D   K   | ]  }|xr |j                   xs d   yw)NoneN)rE   ).0es     r"   	<genexpr>zmatches_re.<locals>.<genexpr>   s!     N(ajj3V3Ns    zR'flags' can only be used with a string pattern; pass flags to re.compile() instead)re	fullmatchsearchmatchformatjoinsortedsetrQ   r2   r   r6   compilerM   )regexflagsfuncvalid_funcsr<   rP   rO   s          r"   r   r      s    * <<ryy"((;K;)00IINS=MNN

 o%!fCC. **UE*rxx]]
		^^
&&
w
33r#   c                   &    e Zd Z e       Zd Zd Zy)_OptionalValidatorc                 0    |y | j                  |||       y N	validatorr8   r9   r:   r;   s       r"   r=   z_OptionalValidator.__call__   s    =tT5)r#   c                 "    d| j                   dS )Nz<optional validator for z	 or None>rj   rA   s    r"   rB   z_OptionalValidator.__repr__   s    )$..);9EEr#   N)rE   rF   rG   r
   rk   r=   rB   r%   r#   r"   rg   rg      s    I*Fr#   rg   c                 l    t        | t        t        f      rt        t	        |             S t        |       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.

    Args:
        validator
            (typing.Callable | tuple[typing.Callable] | list[typing.Callable]):
            A validator (or validators) that is used for non-`None` values.

    .. versionadded:: 15.1.0
    .. versionchanged:: 17.1.0 *validator* can be a list of validators.
    .. versionchanged:: 23.1.0 *validator* can also be a tuple of validators.
    )r2   listtuplerg   r   rj   s    r"   r   r      s-     )dE]+!-	":;;i((r#   c                   8    e Zd Z e       Z ed      Zd Zd Zy)_InValidatorF)hashc                     	 || j                   v }|s8d|j                   d| j                  d|d}t	        ||| j                  |      y # t        $ r d}Y Hw xY w)NFr.   z' must be in r0   ))optionsr6   r4   _original_optionsrQ   )r8   r9   r:   r;   
in_optionsr<   s         r"   r=   z_InValidator.__call__   sz    	$,,.J dii[d.D.D-GveYVWXC&&	    	J	s   A AAc                 "    d| j                   dS )Nz<in_ validator with options r?   )rw   rA   s    r"   rB   z_InValidator.__repr__   s    -d.D.D-GqIIr#   N)rE   rF   rG   r
   rv   rw   r=   rB   r%   r#   r"   rr   rr      s    hGE*Jr#   rr   c                 j    | }t        | t        t        t        f      rt	        |       } t        | |      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``, so *options* has to
    support that operation.

    To keep the validator hashable, dicts, lists, and sets are transparently
    transformed into a `tuple`.

    Args:
        options: Allowed options.

    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.
    .. versionchanged:: 24.1.0
       *options* that are a list, dict, or a set are now transformed into a
       tuple to keep the validator hashable.
    )r2   ro   dictr`   rp   rr   )rv   repr_optionss     r"   r   r     s0    8 L'D$,-...r#   c                       e Zd Zd Zd Zy)_IsCallableValidatorc                     t        |      s5d}t        |j                  |j                  ||j                        |      y)r-   z?'{name}' must be callable (got {value!r} that is a {actual!r}).)r4   r;   actual)r<   r;   N)callabler   r]   r4   r5   )r8   r9   r:   r;   messages        r"   r=   z_IsCallableValidator.__call__&  sN     8  #NN% #  	  r#   c                      y)Nz<is_callable validator>r%   rA   s    r"   rB   z_IsCallableValidator.__repr__6  s    (r#   N)rE   rF   rG   r=   rB   r%   r#   r"   r~   r~   $  s     )r#   r~   c                      t               S )a  
    A validator that raises a `attrs.exceptions.NotCallableError` if the
    initializer is called with a value for this particular attribute that is
    not callable.

    .. versionadded:: 19.1.0

    Raises:
        attrs.exceptions.NotCallableError:
            With a human readable error message containing the attribute
            (`attrs.Attribute`) name, and the value it got.
    )r~   r%   r#   r"   r   r   :  s      !!r#   c                   ^    e Zd Z e e             Z ed e e                   Zd Zd Z	y)_DeepIterablerj   Ndefaultrk   c                 v    | j                   | j                  |||       |D ]  }| j                  |||        yr-   Niterable_validatormember_validator)r8   r9   r:   r;   members        r"   r=   z_DeepIterable.__call__Q  sC     "".##D$6 	6F!!$f5	6r#   c                 b    | j                   dnd| j                   }d| d| j                  dS )N  z<deep_iterable validator forz iterables of r?   r   )r8   iterable_identifiers     r"   rB   z_DeepIterable.__repr__[  sP     &&. T,,/0 	 ++>*?T225Q8	
r#   )
rE   rF   rG   r
   r   r   r   r   r=   rB   r%   r#   r"   r   r   J  s0    6 76	
r#   r   c                 V    t        | t        t        f      rt        |  } t	        | |      S )aC  
    A validator that performs deep validation of an iterable.

    Args:
        member_validator: Validator to apply to iterable members.

        iterable_validator:
            Validator to apply to iterable itself (optional).

    Raises
        TypeError: if any sub-validators fail

    .. versionadded:: 19.1.0
    )r2   ro   rp   r	   r   r   r   s     r"   r   r   g  s.     "T5M2!12)+=>>r#   c                   z    e Zd Z e e             Z e e             Z ed e e                   Zd Z	d Z
y)_DeepMappingrj   Nr   c                     | j                   | j                  |||       |D ]+  }| j                  |||       | j                  ||||          - yr   )mapping_validatorkey_validatorvalue_validator)r8   r9   r:   r;   keys        r"   r=   z_DeepMapping.__call__  sY     !!-""4u5 	9CtT3/  tU3Z8	9r#   c                 <    d| j                   d| j                  dS )Nz,<deep_mapping validator for objects mapping z to r?   )r   r   rA   s    r"   rB   z_DeepMapping.__repr__  s(    =d>P>P=SSWX\XlXlWoopqqr#   )rE   rF   rG   r
   r   r   r   r   r   r=   rB   r%   r#   r"   r   r   {  s9    []3M{}5Otx7NO	9rr#   r   c                     t        | ||      S )a  
    A validator that performs deep validation of a dictionary.

    Args:
        key_validator: Validator to apply to dictionary keys.

        value_validator: Validator to apply to dictionary values.

        mapping_validator:
            Validator to apply to top-level mapping attribute (optional).

    .. versionadded:: 19.1.0

    Raises:
        TypeError: if any sub-validators fail
    )r   )r   r   r   s      r"   r   r     s    " 8IJJr#   c                   B    e Zd Z e       Z e       Z e       Zd Zd Zy)_NumberValidatorc                     | j                  || j                        s7d|j                   d| j                   d| j                   d| }t	        |      y)r-   r.   r/   r   : N)compare_funcboundr4   
compare_oprQ   r7   s        r"   r=   z_NumberValidator.__call__  sR       

3dii[
4??*;1TZZL5'RCS/! 4r#   c                 <    d| j                    d| j                   dS )Nz<Validator for x r   r?   )r   r   rA   s    r"   rB   z_NumberValidator.__repr__  s     "4??"31TZZLBBr#   N)	rE   rF   rG   r
   r   r   r   r=   rB   r%   r#   r"   r   r     s"    HEJ8L"Cr#   r   c                 8    t        | dt        j                        S )a  
    A validator that raises `ValueError` if the initializer is called with a
    number larger or equal to *val*.

    The validator uses `operator.lt` to compare the values.

    Args:
        val: Exclusive upper bound for values.

    .. versionadded:: 21.3.0
    <)r   operatorr   vals    r"   r   r          Chkk22r#   c                 8    t        | dt        j                        S )a  
    A validator that raises `ValueError` if the initializer is called with a
    number greater than *val*.

    The validator uses `operator.le` to compare the values.

    Args:
        val: Inclusive upper bound for values.

    .. versionadded:: 21.3.0
    z<=)r   r   r   r   s    r"   r   r          Cx{{33r#   c                 8    t        | dt        j                        S )a  
    A validator that raises `ValueError` if the initializer is called with a
    number smaller than *val*.

    The validator uses `operator.ge` to compare the values.

    Args:
        val: Inclusive lower bound for values

    .. versionadded:: 21.3.0
    z>=)r   r   r   r   s    r"   r   r     r   r#   c                 8    t        | dt        j                        S )a  
    A validator that raises `ValueError` if the initializer is called with a
    number smaller or equal to *val*.

    The validator uses `operator.ge` to compare the values.

    Args:
       val: Exclusive lower bound for values

    .. versionadded:: 21.3.0
    r?   )r   r   r   r   s    r"   r   r     r   r#   c                   &    e Zd Z e       Zd Zd Zy)_MaxLengthValidatorc                     t        |      | j                  kD  r3d|j                   d| j                   dt        |       }t        |      y)r-   Length of 'z' must be <= r   N)len
max_lengthr4   rQ   r7   s        r"   r=   z_MaxLengthValidator.__call__  H     u:'		{-7H3u:,WCS/! (r#   c                 "    d| j                    dS )Nz<max_len validator for r?   )r   rA   s    r"   rB   z_MaxLengthValidator.__repr__      ((9;;r#   N)rE   rF   rG   r
   r   r=   rB   r%   r#   r"   r   r         J"<r#   r   c                     t        |       S )z
    A validator that raises `ValueError` if the initializer is called
    with a string or iterable that is longer than *length*.

    Args:
        length (int): Maximum length of the string or iterable

    .. versionadded:: 21.3.0
    )r   lengths    r"   r   r          v&&r#   c                   &    e Zd Z e       Zd Zd Zy)_MinLengthValidatorc                     t        |      | j                  k  r3d|j                   d| j                   dt        |       }t        |      y)r-   r   z' must be >= r   N)r   
min_lengthr4   rQ   r7   s        r"   r=   z_MinLengthValidator.__call__  r   r#   c                 "    d| j                    dS )Nz<min_len validator for r?   )r   rA   s    r"   rB   z_MinLengthValidator.__repr__  r   r#   N)rE   rF   rG   r
   r   r=   rB   r%   r#   r"   r   r     r   r#   r   c                     t        |       S )z
    A validator that raises `ValueError` if the initializer is called
    with a string or iterable that is shorter than *length*.

    Args:
        length (int): Minimum length of the string or iterable

    .. versionadded:: 22.1.0
    )r   r   s    r"   r   r     r   r#   c                   &    e Zd Z e       Zd Zd Zy)_SubclassOfValidatorc                     t        || j                        s8d|j                   d| j                  d|d}t        ||| j                  |      y)r-   r.   z' must be a subclass of r0   r1   N)
issubclassr3   r4   r6   r7   s        r"   r=   z_SubclassOfValidator.__call__0  sX     %+dii[ 8VE9TVWC			  ,r#   c                 "    d| j                   dS )Nz <subclass_of validator for type r?   r@   rA   s    r"   rB   z_SubclassOfValidator.__repr__=  rC   r#   NrD   r%   r#   r"   r   r   ,  rH   r#   r   c                     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
    `issubclass` therefore it's also valid to pass a tuple of types).

    Args:
        type (type | tuple[type, ...]): The type(s) to check for.

    Raises:
        TypeError:
            With a human readable error message, the attribute (of type
            `attrs.Attribute`), the expected type, and the value it got.
    )r   r@   s    r"   _subclass_ofr   A  rJ   r#   c                   ~    e Zd Z e       Z e ed            Z e e ee	       e
e                  Zd Zd Zy)_NotValidatorzCnot_ validator child '{validator!r}' did not raise a captured error)	converterr   rj   c                     	 | j                  |||       t        | j                  j                  | j                   | j                        || j                   || j                        # | j                  $ r Y y w xY w)Nrk   	exc_types)rk   rQ   r<   r]   r   rl   s       r"   r=   z_NotValidator.__call__b  sw    	NN4u- "nn"nn    	 	 ~~ 		s   A' 'A98A9c                 <    d| j                   d| j                  dS )Nz<not_ validator wrapping z, capturing r?   r   rA   s    r"   rB   z_NotValidator.__repr__s  s"    *4>>*<LHZZ[\\r#   N)rE   rF   rG   r
   rk   r   r<   r   r   	Exceptionr   rp   r   r=   rB   r%   r#   r"   r   r   R  sO    I
!-
C ))4*51
I"]r#   r   )r<   r   c                X    	 t        |      }t        | ||      S # t        $ r |f}Y w xY w)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_(...))``.

    Args:
        validator: A validator to be logically inverted.

        msg (str):
            Message to raise if validator fails. Formatted with keys
            ``exc_types`` and ``validator``.

        exc_types (tuple[type, ...]):
            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
    )rp   r6   r   )rk   r<   r   s      r"   r   r   w  s:    :!)$	 C33  !L	!s    ))c                   &    e Zd Z e       Zd Zd Zy)_OrValidatorc                     | j                   D ]  }	  ||||        y  d| j                   d|}t        |      # t        $ r Y 9w xY w)NzNone of z satisfied for value )
validatorsr   rQ   )r8   r9   r:   r;   vr<   s         r"   r=   z_OrValidator.__call__  sc     	A$e$ 	 ++@	Jo  s   
;	AAc                 "    d| j                   dS )Nz<or validator wrapping r?   )r   rA   s    r"   rB   z_OrValidator.__repr__  s    ((;1==r#   N)rE   rF   rG   r
   r   r=   rB   r%   r#   r"   r   r     s    J
>r#   r   c                      g }| D ]0  }|j                  t        |t              r|j                  n|g       2 t        t	        |            S )a  
    A validator that composes multiple validators into one.

    When called on a value, it runs all wrapped validators until one of them is
    satisfied.

    Args:
        validators (~collections.abc.Iterable[typing.Callable]):
            Arbitrary number of validators.

    Raises:
        ValueError:
            If no validator is satisfied. Raised with a human-readable error
            message listing all the wrapped validators and the value that
            failed all of them.

    .. versionadded:: 24.1.0
    )extendr2   r   r   rp   )r   valsr   s      r"   r   r     sH    & D JJq,$?ALLaSIJ d$$r#   )r   Nri   )5__doc__r   rY   
contextlibr   r   _configr   r   _maker   r	   r
   r   
convertersr   
exceptionsr   __all__r   r   r   r+   r   rM   r   rg   r   rr   r   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rQ   r6   r   r   r   r%   r#   r"   <module>r      s    	 %  ; 5 5 ' (.%$	$ ! !" E40A A 1A(&" E$d+F F ,F*-4` E40
F 
F 1
F)* E40J J 1J. /F ED1) ) 2)*"  E40
 
 1
8?( E40r r 1r(K( E$d+C C ,C"3443 E$d+< < ,<
' E$d+< < ,<
' E40A A 1A(&" E40!] !] 1!]H  J	+B !4H E40> > 1>&%r#   