
    i1T                     2   S r SSKrSSKrSSKJr  SSKJr  SSKJrJr  SSK	J
r
JrJrJr  SSKJr  SS	KJr  / S
QrS rS r\S 5       r\" SSSS9 " S S5      5       rS r\" SSSS9 " S S5      5       rS=S jr\" SSSS9 " S S5      5       rS r\" SSSS9 " S S5      5       rS r\" SSSS9 " S S5      5       rS  r\" SSSS9 " S! S"5      5       r S>S# jr!\" SSSS9 " S$ S%5      5       r" S?S& jr#\" SSSS9 " S' S(5      5       r$S) r%S* r&S+ r'S, r(\" SSSS9 " S- S.5      5       r)S/ r*\" SSSS9 " S0 S15      5       r+S2 r,\" SSSS9 " S3 S45      5       r-S5 r.\" SSSS9 " S6 S75      5       r/S\0\14S8.S9 jr2\" SSSS9 " S: S;5      5       r3S< r4g)@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                 $    [        U (       + 5        g)z
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    N/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/attr/validators.pyr    r    *   s     8|$    c                       [        5       (       + $ )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               #   v   #    [        5       n [        S5         Sv   [        U 5        g! [        U 5        f = f7f)z
Context manager that disables running validators within its context.

.. warning::

    This context manager is not thread-safe!

.. versionadded:: 21.3.0
.. versionchanged:: 26.1.0 The contextmanager is nestable.
FNr   )prevs    r"   r   r   H   s0      Du!4 4 s   9) 969FT)reprslotsunsafe_hashc                   .    \ rS rSr\" 5       rS rS rSrg)_InstanceOfValidator\   c           	          [        X0R                  5      (       dH  SUR                   SU R                  < SU< SUR                  < S3	n[	        UUU R                  U5      eg)@
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___InstanceOfValidator.__call__`   sf     %++dii[
499-veYkRWRaRaQddfgC			  ,r#   c                 $    SU R                   < S3$ )Nz <instance_of validator for type >r5   r:   s    r"   __repr___InstanceOfValidator.__repr__m       1$))a@@r#   r%   N	__name__
__module____qualname____firstlineno__r   r5   r?   rE   __static_attributes__r%   r#   r"   r,   r,   \       8DAr#   r,   c                     [        U 5      $ )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,   rC   s    r"   r   r   q         %%r#   )r(   frozenr)   c                   <    \ rS rSr\" 5       r\" 5       rS rS rSr	g)_MatchesReValidator   c                     U R                  U5      (       dD  SUR                   SU R                  R                  < SU< S3n[        UUU R                  U5      eg)r/   r0   z' must match regex z (z	 doesn't)N)
match_funcr6   pattern
ValueErrorr9   s        r"   r?   _MatchesReValidator.__call__   s`     u%%dii[ 3DLL4H4H3K2eYV_`C	  &r#   c                 $    SU R                   < S3$ )Nz"<matches_re validator for pattern rB   )rW   rD   s    r"   rE   _MatchesReValidator.__repr__   s    3DLL3C1EEr#   r%   N)
rI   rJ   rK   rL   r   rW   rV   r?   rE   rM   r%   r#   r"   rS   rS      s    hGJFr#   rS   c           
      &   [         R                  S[         R                  [         R                  4nX#;  aD  SR	                  SR                  [        S [        U5       5       5      5      5      n[        U5      e[        U [        5      (       a  U(       a  Sn[        U5      eU nO[         R                  " X5      nU[         R                  L a  UR                  nO,U[         R                  L a  UR                  nOUR                  n[        XV5      $ )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   \   #    U  H"  o=(       a    UR                   =(       d    S v   M$     g7f)NoneN)rI   ).0es     r"   	<genexpr>matches_re.<locals>.<genexpr>   s!     N=M(ajj3V3=Ms   *,zR'flags' can only be used with a string pattern; pass flags to re.compile() instead)re	fullmatchsearchmatchformatjoinsortedsetrX   r4   r   r8   compilerS   )regexflagsfuncvalid_funcsr>   rW   rV   s          r"   r   r      s    * <<ryy"((;K)00IINS=MNN

 o%!!fCC. **U*rxx]]
		^^
&&
w33r#   c                   .    \ rS rSr\" 5       rS rS rSrg)_OptionalValidator   c                 0    Uc  g U R                  XU5        g N	validatorr:   r;   r<   r=   s       r"   r?   _OptionalValidator.__call__   s    =t5)r#   c                 $    SU R                   < S3$ )Nz<optional validator for z	 or None>ru   rD   s    r"   rE   _OptionalValidator.__repr__   s    )$..);9EEr#   r%   N)	rI   rJ   rK   rL   r   rv   r?   rE   rM   r%   r#   r"   rq   rq      s    I*Fr#   rq   c                 v    [        U [        [        45      (       a  [        [	        U 5      5      $ [        U 5      $ )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.
)r4   listtuplerq   r	   ru   s    r"   r   r      s0     )dE]++!-	":;;i((r#   c                   :    \ rS rSr\" 5       r\" SS9rS rS rSr	g)_InValidator   F)hashc                      X0R                   ;   nU(       d:  SUR                   SU R                  < SU< S3n[	        UUU R                  U5      eg ! [         a    Sn NPf = f)NFr0   z' must be in r2   ))optionsr8   r6   _original_optionsrX   )r:   r;   r<   r=   
in_optionsr>   s         r"   r?   _InValidator.__call__   sx    	,,.J dii[d.D.D-GveYVWXC&&	    	J	s   A A! A!c                 $    SU R                   < S3$ )Nz<in_ validator with options rB   )r   rD   s    r"   rE   _InValidator.__repr__   s    -d.D.D-GqIIr#   r%   N)
rI   rJ   rK   rL   r   r   r   r?   rE   rM   r%   r#   r"   r   r      s    hGE*Jr#   r   c                 r    U n[        U [        [        [        45      (       a  [	        U 5      n [        X5      $ )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.
)r4   r|   dictrj   r}   r   )r   repr_optionss     r"   r   r     s1    8 L'D$,--...r#   c                        \ rS rSrS rS rSrg)_IsCallableValidatori&  c                     [        U5      (       d.  Sn[        UR                  UR                  X3R                  S9US9eg)r/   z?'{name}' must be callable (got {value!r} that is a {actual!r}).)r6   r=   actual)r>   r=   N)callabler   rg   r6   r7   )r:   r;   r<   r=   messages        r"   r?   _IsCallableValidator.__call__(  sN     8  #NN% #  	  r#   c                     g)Nz<is_callable validator>r%   rD   s    r"   rE   _IsCallableValidator.__repr__8  s    (r#   r%   N)rI   rJ   rK   rL   r?   rE   rM   r%   r#   r"   r   r   &  s     )r#   r   c                      [        5       $ )ad  
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                   Z    \ rS rSr\" \" 5       S9r\" S\" \" 5       5      S9rS r	S r
Srg)_DeepIterableiL  ru   N)defaultrv   c                 x    U R                   b  U R                  XU5        U H  nU R                  XU5        M     gr/   Niterable_validatormember_validator)r:   r;   r<   r=   members        r"   r?   _DeepIterable.__call__S  s:     "".##D6F!!$f5 r#   c                 h    U R                   c  SOSU R                   < 3nSU SU R                  < S3$ )N  z<deep_iterable validator forz iterables of rB   r   )r:   iterable_identifiers     r"   rE   _DeepIterable.__repr__]  sP     &&. T,,/0 	 ++>*?T225Q8	
r#   r%   )rI   rJ   rK   rL   r   r   r   r   r   r?   rE   rM   r%   r#   r"   r   r   L  s0    6 76	
r#   r   c                     [        U [        [        45      (       a  [        U 6 n [        U[        [        45      (       a  [        U6 n[	        X5      $ )a  
A validator that performs deep validation of an iterable.

Args:
    member_validator: Validator(s) to apply to iterable members.

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

Raises
    TypeError: if any sub-validators fail

.. versionadded:: 19.1.0

.. versionchanged:: 25.4.0
   *member_validator* and *iterable_validator* can now be a list or tuple
   of validators.
)r4   r|   r}   r
   r   r   r   s     r"   r   r   i  sL    & "T5M22!12$tUm44!#56)>>r#   c                       \ rS rSr\" \" \" 5       5      S9r\" \" \" 5       5      S9r\" \" \" 5       5      S9r	S r
S rSrg)_DeepMappingi  ru   c                     U R                   b  U R                  XU5        U HE  nU R                  b  U R                  XU5        U R                  c  M1  U R                  XX4   5        MG     gr   )mapping_validatorkey_validatorvalue_validator)r:   r;   r<   r=   keys        r"   r?   _DeepMapping.__call__  sd     !!-""4u5C!!-""4s3##/$$T<	 r#   c                 @    SU R                   < SU R                  < S3$ )Nz,<deep_mapping validator for objects mapping z to rB   )r   r   rD   s    r"   rE   _DeepMapping.__repr__  s(    =d>P>P=SSWX\XlXlWoopqqr#   r%   N)rI   rJ   rK   rL   r   r   r   r   r   r   r?   rE   rM   r%   r#   r"   r   r     sA    Xkm%<=Mx'>?O+-)@A=rr#   r   c                    U c  Uc  Sn[        U5      e[        U [        [        45      (       a  [	        U 6 n [        U[        [        45      (       a  [	        U6 n[        U[        [        45      (       a  [	        U6 n[        XU5      $ )aZ  
A validator that performs deep validation of a dictionary.

All validators are optional, but at least one of *key_validator* or
*value_validator* must be provided.

Args:
    key_validator: Validator(s) to apply to dictionary keys.

    value_validator: Validator(s) to apply to dictionary values.

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

.. versionadded:: 19.1.0

.. versionchanged:: 25.4.0
   *key_validator* and *value_validator* are now optional, but at least one
   of them must be provided.

.. versionchanged:: 25.4.0
   *key_validator*, *value_validator*, and *mapping_validator* can now be a
   list or tuple of validators.

Raises:
    TypeError: If any sub-validator fails on validation.

    ValueError:
        If neither *key_validator* nor *value_validator* is provided on
        instantiation.
zAAt least one of key_validator or value_validator must be provided)rX   r4   r|   r}   r
   r   )r   r   r   r>   s       r"   r   r     s    D !8O 	 o-$//m,/D%=110#dE]33 "348IJJr#   c                   J    \ rS rSr\" 5       r\" 5       r\" 5       rS rS r	Sr
g)_NumberValidatori  c                     U R                  X0R                  5      (       d7  SUR                   SU R                   SU R                   SU 3n[	        U5      eg)r/   r0   r1   r   : N)compare_funcboundr6   
compare_oprX   r9   s        r"   r?   _NumberValidator.__call__  sS       

33dii[
4??*;1TZZL5'RCS/! 4r#   c                 <    SU R                    SU R                   S3$ )Nz<Validator for x r   rB   )r   r   rD   s    r"   rE   _NumberValidator.__repr__  s     "4??"31TZZLBBr#   r%   N)rI   rJ   rK   rL   r   r   r   r   r?   rE   rM   r%   r#   r"   r   r     s"    HEJ8L"Cr#   r   c                 8    [        U S[        R                  5      $ )z
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    [        U S[        R                  5      $ )z
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    [        U S[        R                  5      $ )z
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    [        U S[        R                  5      $ )z
A validator that raises `ValueError` if the initializer is called with a
number smaller or equal to *val*.

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

Args:
   val: Exclusive lower bound for values

.. versionadded:: 21.3.0
rB   )r   r   r   r   s    r"   r   r     r   r#   c                   .    \ rS rSr\" 5       rS rS rSrg)_MaxLengthValidatori  c                     [        U5      U R                  :  a3  SUR                   SU R                   S[        U5       3n[        U5      eg)r/   Length of 'z' must be <= r   N)len
max_lengthr6   rX   r9   s        r"   r?   _MaxLengthValidator.__call__  H     u:'		{-7H3u:,WCS/! (r#   c                 "    SU R                    S3$ )Nz<max_len validator for rB   )r   rD   s    r"   rE   _MaxLengthValidator.__repr__&      ((9;;r#   r%   N)	rI   rJ   rK   rL   r   r   r?   rE   rM   r%   r#   r"   r   r         J"<r#   r   c                     [        U 5      $ )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                   .    \ rS rSr\" 5       rS rS rSrg)_MinLengthValidatori7  c                     [        U5      U R                  :  a3  SUR                   SU R                   S[        U5       3n[        U5      eg)r/   r   z' must be >= r   N)r   
min_lengthr6   rX   r9   s        r"   r?   _MinLengthValidator.__call__;  r   r#   c                 "    SU R                    S3$ )Nz<min_len validator for rB   )r   rD   s    r"   rE   _MinLengthValidator.__repr__C  r   r#   r%   N)	rI   rJ   rK   rL   r   r   r?   rE   rM   r%   r#   r"   r   r   7  r   r#   r   c                     [        U 5      $ )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   G  r   r#   c                   .    \ rS rSr\" 5       rS rS rSrg)_SubclassOfValidatoriT  c                     [        X0R                  5      (       d:  SUR                   SU R                  < SU< S3n[        UUU R                  U5      eg)r/   r0   z' must be a subclass of r2   r3   N)
issubclassr5   r6   r8   r9   s        r"   r?   _SubclassOfValidator.__call__X  sY     %++dii[ 8VE9TVWC			  ,r#   c                 $    SU R                   < S3$ )Nz <subclass_of validator for type rB   rC   rD   s    r"   rE   _SubclassOfValidator.__repr__e  rG   r#   r%   NrH   r%   r#   r"   r   r   T  rN   r#   r   c                     [        U 5      $ )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   rC   s    r"   _subclass_ofr   i  rP   r#   c                   t    \ rS rSr\" 5       r\" \" S5      S9r\" \" \	" \
5      \" \5      S9S9rS rS rSrg	)
_NotValidatoriz  zCnot_ validator child '{validator!r}' did not raise a captured error)	converterr   ru   c                      U R                  XU5        [        U R                  R                  U R                   U R                  S9UU R                   UU R                  5      e! U R                   a     g f = f)Nrv   	exc_types)rv   rX   r>   rg   r   rw   s       r"   r?   _NotValidator.__call__  su    	NN4u- "nn"nn    	 	 ~~ 		s   A# #A65A6c                 @    SU R                   < SU R                  < S3$ )Nz<not_ validator wrapping z, capturing rB   r   rD   s    r"   rE   _NotValidator.__repr__  s"    *4>>*<LHZZ[\\r#   r%   N)rI   rJ   rK   rL   r   rv   r   r>   r   r   	Exceptionr   r}   r   r?   rE   rM   r%   r#   r"   r   r   z  sO    I
!-
C ))4*51
I"]r#   r   )r>   r   c                X     [        U5      n[        XU5      $ ! [         a    U4n Nf = f)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
)r}   r8   r   )rv   r>   r   s      r"   r   r     s8    :!)$	 33  !L	!s    ))c                   .    \ rS rSr\" 5       rS rS rSrg)_OrValidatori  c                     U R                    H  n U" XU5          g    SU R                   < SU< 3n[        U5      e! [         a     M=  f = f)NzNone of z satisfied for value )
validatorsr   rX   )r:   r;   r<   r=   vr>   s         r"   r?   _OrValidator.__call__  s\    A$e$  ! ++@	Jo  s   	=
A
Ac                 $    SU R                   < S3$ )Nz<or validator wrapping rB   )r   rD   s    r"   rE   _OrValidator.__repr__  s    ((;1==r#   r%   N)	rI   rJ   rK   rL   r   r   r?   rE   rM   r%   r#   r"   r   r     s    J
>r#   r   c                      / nU  H6  nUR                  [        U[        5      (       a  UR                  OU/5        M8     [        [	        U5      5      $ )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
)extendr4   r   r   r}   )r   valsr   s      r"   r   r     sD    & DJq,$?$?ALLaSI  d$$r#   )r   Nrt   )NNN)5__doc__r   rc   
contextlibr   r   _configr   r   _maker	   r
   r   r   
convertersr   
exceptionsr   __all__r    r   r   r,   r   rS   r   rq   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rX   r8   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?4 E40r r 1r. AE/Kd 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#   