
    fx'                        d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	  G d de
      Ze G d	 d
ej                  j                               Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Z G d' d(e      Z G d) d*e      Z G d+ d,e      Z G d- d.ee      Z  G d/ d0ej                  jB                        Z" G d1 d2ej                  jB                        Z# G d3 d4ej                  jB                        Z$ G d5 d6ej                  jB                        Z% G d7 d8ej                  jB                        Z& G d9 d:e'      Z( e(       Z(y);z+Bootstrap schema interfaces and exceptions
    )total_orderingN)	Attribute)
IInterface)_c                       e Zd ZdZy)StopValidationzRaised if the validation is completed early.

    Note that this exception should be always caught, since it is just
    a way for the validator to save time.
    N__name__
__module____qualname____doc__     x/var/dept/share/cheung/public_html/OutSchool/python/env/lib/python3.12/site-packages/zope/schema/_bootstrapinterfaces.pyr   r          r   r   c                   v    e Zd ZdZdZdZd Zd Zd Zd Z	e
j                  j                  j                  Zd Zy)ValidationErrorz'Raised if the Validation process fails.Nc                 "    || _         || _        | S N)fieldvalue)selfr   r   s      r   with_field_and_valuez$ValidationError.with_field_and_value/   s    

r   c                 .    | j                   j                  S r   )	__class__r   r   s    r   doczValidationError.doc4   s    ~~%%%r   c                 N    t        |d      sy| j                  |j                  k  S )NargsThasattrr   r   others     r   __lt__zValidationError.__lt__7   s$     uf%yy5::%%r   c                 N    t        |d      sy| j                  |j                  k(  S )Nr   Fr    r"   s     r   __eq__zValidationError.__eq__>   s"    uf%yyEJJ&&r   c                 z    | j                   j                  ddj                  d | j                  D              dS )N(z, c              3   2   K   | ]  }t        |        y wr   )repr).0args     r   	<genexpr>z+ValidationError.__repr__.<locals>.<genexpr>J   s     5Cd3i5s   ))r   r
   joinr   r   s    r   __repr__zValidationError.__repr__G   s/    NN##II5499557 	7r   )r
   r   r   r   r   r   r   r   r$   r&   zope	interfaceInvalid__hash__r0   r   r   r   r   r   %   sC    1 E E
&&' ~~%%..H7r   r   c                       e Zd Z ed      Zy)RequiredMissingzRequired input is missing.Nr
   r   r   r   r   r   r   r   r6   r6   M   s    01Gr   r6   c                   (    e Zd Z ed      ZdZddZy)	WrongTypezObject is of wrong type.Nc                 R    t        j                  | |||g|  || _        || _        y)z
        WrongType(value, expected_type, name)

        .. versionchanged:: 4.7.0
           Added named arguments to the constructor and the `expected_type`
           field.
        N)r   __init__expected_typer   )r   r   r<   namer   s        r   r;   zWrongType.__init__Y   s,     	  umTIDI*
r   )NNN)r
   r   r   r   r   r<   r;   r   r   r   r9   r9   Q   s    ./G
 M
r   r9   c                   p     e Zd ZdZdZ  eddddi             Z  eddddi             ZdZd fd	Z	 xZ
S )	OutOfBoundsa  
    A value was out of the allowed bounds.

    This is the common superclass for `OrderableOutOfBounds` and
    `LenOutOfBounds`, which in turn are the superclasses for `TooBig`
    and `TooSmall`, and `TooLong` and `TooShort`, respectively.

    .. versionadded:: 4.7.0
    N	TOO_LARGEr   	__slots__	TOO_SMALLc                 L    t        t        | 
  ||g|  || _        || _        y)z+
        OutOfBounds(value, bound)
        N)superr?   r;   r   bound)r   r   rE   r   r   s       r   r;   zOutOfBounds.__init__   s)     	k4)%>>

r   NN)r
   r   r   r   rE   typer@   rB   violation_directionr;   __classcell__r   s   @r   r?   r?   f   sU     E 9["{B&78:I 9["{B&78:I  r   r?   c                       e Zd ZdZy)OrderableOutOfBoundszg
    A value was too big or too small in comparison to another value.

    .. versionadded:: 4.7.0
    Nr	   r   r   r   rL   rL      r   r   rL   c                   4    e Zd Z ed      Zej                  Zy)TooBigzValue is too bigNr
   r   r   r   r   r?   r@   rH   r   r   r   rN   rN      s    &'G%//r   rN   c                   4    e Zd Z ed      Zej                  Zy)TooSmallzValue is too smallNr
   r   r   r   r   r?   rB   rH   r   r   r   rQ   rQ          ()G%//r   rQ   c                       e Zd ZdZy)LenOutOfBoundszQ
    The length of the value was out of bounds.

    .. versionadded:: 4.7.0
    Nr	   r   r   r   rU   rU      r   r   rU   c                   4    e Zd Z ed      Zej                  Zy)TooLongzValue is too longNrO   r   r   r   rW   rW      s    '(G%//r   rW   c                   4    e Zd Z ed      Zej                  Zy)TooShortzValue is too shortNrR   r   r   r   rY   rY      rS   r   rY   c                       e Zd Z ed      Zy)InvalidValuezInvalid valueNr7   r   r   r   r[   r[      s    #$Gr   r[   c                       e Zd Z ed      Zy)ConstraintNotSatisfiedzConstraint not satisfiedNr7   r   r   r   r]   r]      s    ./Gr   r]   c                       e Zd Z ed      Zy)NotAContainerzNot a containerNr7   r   r   r   r_   r_          %&Gr   r_   c                       e Zd Z ed      Zy)NotAnIteratorzNot an iteratorNr7   r   r   r   rb   rb      r`   r   rb   c                   4     e Zd Z ed      ZdZd fd	Z xZS )WrongContainedTypezWrong contained typer   c                 >    t        t        | 
  ||g|  || _        y)z
        WrongContainedType(errors, name)

        .. versionchanged:: 4.7.0
           Added named arguments to the constructor, and the `errors` property.
        N)rD   rd   r;   errors)r   rf   r=   r   r   s       r   r;   zWrongContainedType.__init__   s#     	 $0EEr   rF   )r
   r   r   r   r   rf   r;   rI   rJ   s   @r   rd   rd      s    *+G F r   rd   c                   <     e Zd Z ed      ZdZdZ	 	 d fd	Z xZS )SchemaNotCorrectlyImplementedz0An object failed schema or invariant validation.Nr   c                 L    t        t        | 
  ||g|  || _        || _        y)z
        SchemaNotCorrectlyImplemented(errors, name, schema_errors,
                                      invariant_errors)

        .. versionchanged:: 4.7.0
           Added named arguments to the constructor.
        N)rD   rh   r;   schema_errorsinvariant_errors)r   rf   r=   rj   rk   r   r   s         r   r;   z&SchemaNotCorrectlyImplemented.__init__   s2     	+T;D	!	!* 0r   )NNNr   )	r
   r   r   r   r   rj   rk   r;   rI   rJ   s   @r   rh   rh      s-    FGG M =A"$1 1r   rh   c                       e Zd Z ed      Zy)SchemaNotFullyImplementedzSchema not fully implementedNr7   r   r   r   rm   rm      s    23Gr   rm   c                   4     e Zd Z ed      ZdZd fd	Z xZS )SchemaNotProvidedzSchema not providedNc                 L    t        t        | 
  ||g|  || _        || _        y)z
        SchemaNotProvided(schema, value)

        .. versionchanged:: 4.7.0
           Added named arguments to the constructor and the `schema` property.
        N)rD   ro   r;   schemar   )r   rq   r   r   r   s       r   r;   zSchemaNotProvided.__init__   s*     	/EE
r   rF   )r
   r   r   r   r   rq   r;   rI   rJ   s   @r   ro   ro      s    )*G F	 	r   ro   c                   &     e Zd ZdZeZ fdZ xZS )NotAnInterfacea  
    Object is not an interface.

    This is a `WrongType` exception for backwards compatibility with
    existing ``except`` clauses, but it is raised when
    ``IInterface.providedBy`` is not true, so it's also a
    `SchemaNotProvided`. The ``expected_type`` field is filled in as
    ``IInterface``; this is not actually a `type`, and
    ``isinstance(thing, IInterface)`` is always false.

    .. versionadded:: 4.7.0
    c                 8    t         t        |   |t        |       y r   )rD   rs   r;   r   )r   r   r=   r   s      r   r;   zNotAnInterface.__init__  s    nd,UJEr   )r
   r   r   r   r   r<   r;   rI   rJ   s   @r   rs   rs     s     MF Fr   rs   c                       e Zd ZdZd Zy)IFromUnicodezParse a unicode string to a value

    We will often adapt fields to this interface to support views and
    other applications that need to convert raw data as unicode
    values.
    c                      y)z-Convert a unicode string to a value.
        Nr   r   s    r   fromUnicodezIFromUnicode.fromUnicode"      r   N)r
   r   r   r   ry   r   r   r   rv   rv     s    r   rv   c                       e Zd ZdZd Zy)
IFromBytesz
    Parse a byte string to a value.

    If the string needs to be decoded, decoding is done using UTF-8.

    .. versionadded:: 4.8.0
    c                      y)z*Convert a byte string to a value.
        Nr   rx   s    r   	fromByteszIFromBytes.fromBytes0  rz   r   N)r
   r   r   r   r~   r   r   r   r|   r|   '  s    r   r|   c                       e Zd ZdZd Zy)IContextAwareDefaultFactoryzA default factory that requires a context.

    The context is the field context. If the field is not bound, context may
    be ``None``.
    c                      y)z&Returns a default value for the field.Nr   )contexts    r   __call__z$IContextAwareDefaultFactory.__call__<  rz   r   N)r
   r   r   r   r   r   r   r   r   r   5  s    5r   r   c                   @    e Zd ZdZ ed      Z ed      Z ed      Zy)IBeforeObjectAssignedEventa9  An object is going to be assigned to an attribute on another object.

    Subscribers to this event can change the object on this event to change
    what object is going to be assigned. This is useful, e.g. for wrapping
    or replacing objects before they get assigned to conform to application
    policy.
    z(The object that is going to be assigned.zBThe name of the attribute under which the object will be assigned.z8The context object where the object will be assigned to.N)r
   r   r   r   r   objectr=   r   r   r   r   r   r   @  s4     ABF ) *D  ' (Gr   r   c                       e Zd Zd Zy)IValidatablec                      y)zValidate that the given value is a valid field value.

        Returns nothing but raises an error if the value is invalid.
        It checks everything specific to a Field and also checks
        with the additional constraint.
        Nr   rx   s    r   validatezIValidatable.validateV  rz   r   N)r
   r   r   r   r   r   r   r   r   R  s    r   r   c                       e Zd Zd Zy)NO_VALUEc                      y)Nz
<NO_VALUE>r   r   s    r   r0   zNO_VALUE.__repr__`  s    r   N)r
   r   r   r0   r   r   r   r   r   _  s    r   r   ))r   	functoolsr   zope.interfacer1   r   zope.interface.interfacesr   zope.schema._messageidr   	Exceptionr   r2   r3   r   r6   r9   r?   rL   rN   rQ   rU   rW   rY   r[   r]   r_   rb   rd   rh   rm   ro   rs   	Interfacerv   r|   r   r   r   r   r   r   r   r   <module>r      s   $  $ 0 $Y  $7dnn,, $7 $7N2o 2 * /  F; 0! 00# 0[ 0n 00~ 0%? %0_ 0'O ''O ' (1$6 144 4 &FY 1 F(
4>>++ 
)) 5$..":": 5(!9!9 ($
4>>++ 
v 
 :r   