
    hJ/                        S r SSKrSSKJrJrJr   " S S\5      r " S S\5      r " S S	5      r	 " S
 S\	5      r
 " S S\
5      r " S S\
5      r " S S\
5      r " S S\
5      r " S S\	5      r " S S\5      r " S S\	5      r " S S\	5      r " S S\	5      r " S S\5      r " S  S!\5      r " S" S#\	5      r " S$ S%\	5      rS& r " S' S(\	5      r " S) S*\5      r " S+ S,5      r " S- S.5      r " S/ S05      rg)1z
Form-based method objects.

This module contains support for descriptive method signatures that can be used
to format methods.
    N)AnyOptionalTuplec                       \ rS rSrSrS rSrg)FormException   z*An error occurred calling the form method.c                 >    [         R                  " U /UQ76   X l        g N)	Exception__init__descriptions)selfargskwargss      `/root/1688_scrapy/alibaba-scraper/venv/lib/python3.13/site-packages/twisted/python/formmethod.pyr   FormException.__init__   s    4'$'"    )r   N)__name__
__module____qualname____firstlineno____doc__r   __static_attributes__ r   r   r   r      s
    4#r   r   c                       \ rS rSrSrSrg)
InputError   z$
An error occurred with some input.
r   Nr   r   r   r   r   r   r   r   r   r   r          r   r   c                   V    \ rS rSr% SrSr\\S'    SS jrS r	SS jr
S rS	 rS
 rSrg)Argument   zBase class for form arguments.NdefaultDefaultc                 |    Xl         X`l        Uc  U R                  nX l        X0l        X@l        U(       d  0 nXPl        g r
   )name	allowNoner#   default	shortDesclongDeschints)r   r%   r'   r(   r)   r*   r&   s          r   r   Argument.__init__%   s:     	"?))G" E
r   c                 :    U R                   R                  U5        g r
   )r*   update)r   r   s     r   addHintsArgument.addHints3   s    

&!r   c                 8    U R                   R                  X5      $ r
   )r*   get)r   r%   r'   s      r   getHintArgument.getHint6   s    zz~~d,,r   c                 \    U R                   =(       d    U R                  R                  5       $ r
   )r(   r%   
capitalizer   s    r   getShortDescriptionArgument.getShortDescription9   s    ~~7!5!5!77r   c                 ,    U R                   =(       d    S$ )N )r)   r6   s    r   getLongDescriptionArgument.getLongDescription<   s    }}""r   c                     [        S5      e)z(Convert the value to the correct format.zimplement in subclass)NotImplementedErrorr   vals     r   coerceArgument.coerce?   s    !"9::r   )r&   r'   r*   r)   r%   r(   )NNNN   r
   )r   r   r   r   r   r#   r   __annotations__r   r.   r2   r7   r;   rA   r   r   r   r   r!   r!      s6    ( NC XY"-8#;r   r!   c                   N    \ rS rSr% SrSr\\S'   SrSr	       S
S jr
S rS	rg)StringD   zA single string.r:   r#   r   Nc	           
      N    [         R                  U UUUUUUS9  Xpl        Xl        g )N)r'   r(   r)   r*   r&   )r!   r   minmax)	r   r%   r'   r(   r)   r*   r&   rI   rJ   s	            r   r   String.__init__K   s8     	 	 	
 r   c                    [        U5      n[        U5      U R                  :  a  [        SU R                  -  5      eU R                  b1  [        U5      U R                  :  a  [        SU R                  -  5      e[        U5      $ )N)Value must be at least %s characters long(Value must be at most %s characters long)strlenrI   r   rJ   )r   r@   ss      r   rA   String.coerceb   sg    Hq6DHHH488STT88CFTXX$5G$((RSS3xr   rJ   rI   )NNNNrC   r   N)r   r   r   r   r   r#   rO   rD   rI   rJ   r   rA   r   r   r   r   rF   rF   D   s:    NC
C
C
 .r   rF   c                       \ rS rSrSrSrg)Textk   zA long string.r   Nr   r   r   r   rU   rU   k   s    r   rU   c                       \ rS rSrSrSrg)Passwordo   z-A string which should be obscured when input.r   Nr   r   r   r   rX   rX   o   s    7r   rX   c                       \ rS rSrSrS rSrg)VerifiedPasswords   zCA string that should be obscured when input and needs verification.c                 L   [        U5      S:w  d  US   US   :w  a  [        S5      e[        US   5      n[        U5      U R                  :  a  [        SU R                  -  5      eU R                  b1  [        U5      U R                  :  a  [        SU R                  -  5      eU$ )N   r   rC   z%Please enter the same password twice.rM   rN   )rP   r   rO   rI   rJ   )r   valsrQ   s      r   rA   VerifiedPassword.coercev   s    t9>T!WQ/DEEQLq6DHHH488STT88CFTXX$5G$((RSSr   r   N)r   r   r   r   r   rA   r   r   r   r   r[   r[   s   s
    Mr   r[   c                       \ rS rSrSrSrg)Hidden   zKA string which is not displayed.

The passed default is used as the value.
r   Nr   r   r   r   rb   rb      s    r   rb   c                   @    \ rS rSr% SrSr\\   \S'    SS jr	S r
Srg)	Integer   zA single integer.Nr#   c           	      4    [         R                  XX4XVU5        g r
   r!   r   r   r%   r&   r'   r(   r)   r*   s          r   r   Integer.__init__        	$g(9Ur   c                     UR                  5       (       d  U R                  (       a  g  [        U5      $ ! [         a    [	        SR                  U5      5      ef = f)Nz5{} is not valid, please enter a whole number, e.g. 10)stripr&   int
ValueErrorr   formatr?   s     r   rA   Integer.coerce   sO    yy{{t~~	s8O 	JQQRUV 	s	   
4 %Ar   rC   NNNN)r   r   r   r   r   r#   r   rn   rD   r   rA   r   r   r   r   re   re      s%    $(NHSM( UYVr   re   c                   .    \ rS rSr     SS jrS rSrg)IntegerRange   Nc	           
      N    X l         X0l        [        R                  U UUUUUUS9  g )N)r&   r'   r(   r)   r*   )rI   rJ   re   r   )	r   r%   rI   rJ   r&   r'   r(   r)   r*   s	            r   r   IntegerRange.__init__   s6      	 	
r   c                 .   [         R                  X5      nU R                  (       a  US :X  a  U$ X R                  :  a$  [	        SR                  X R                  5      5      eX R                  :  a$  [	        SR                  X R                  5      5      eU$ )Nz/Value {} is too small, it should be at least {}z.Value {} is too large, it should be at most {})re   rA   r&   rI   r   rp   rJ   )r   r@   results      r   rA   IntegerRange.coerce   s    *>>fnMHHAHHHH 
 HH@GGHH 
 r   rS   rr   r   r   r   r   r   rA   r   r   r   r   rt   rt      s     
.r   rt   c                   <    \ rS rSr% Sr\\   \S'    SS jrS r	Sr
g)Float   Nr#   c           	      4    [         R                  XX4XVU5        g r
   rh   ri   s          r   r   Float.__init__   rk   r   c                     UR                  5       (       d  U R                  (       a  g  [        U5      $ ! [         a    [	        SU-  5      ef = f)NzInvalid float: %s)rm   r&   floatro   r   r?   s     r   rA   Float.coerce   sE    yy{{t~~	8: 	803677	8s	   
4 Ar   rr   )r   r   r   r   r#   r   r   rD   r   rA   r   r   r   r   r}   r}      s"    &*NHUO* UYV8r   r}   c                   4    \ rS rSrSr/ / SSSS4S jrS rSrg)Choice   a  
The result of a choice between enumerated types.  The choices should
be a list of tuples of tag, value, and description.  The tag will be
the value returned if the user hits "Submit", and the description
is the bale for the enumerated type.  default is a list of all the
values (seconds element in choices).  If no defaults are specified,
initially the first item will be selected.  Only one item can (should)
be selected at once.
NrC   c           
          X l         U(       a  U(       d  UR                  US   S   5        [        R                  XX4XVUS9  g )Nr   rC   r&   )choicesappendr!   r   )r   r%   r   r'   r(   r)   r*   r&   s           r   r   Choice.__init__   s>     7NN71:a=)Hy 	 	
r   c                 \    U R                    H  u  p#nX!:X  d  M  Us  $    [        SU-  5      e)NzInvalid Choice: %s)r   r   )r   inIdentidentr@   descs        r   rA   Choice.coerce   s3     $E
 !- 1G;<<r   )r   r   r   r   r   r   r   rA   r   r   r   r   r   r      s%     
"=r   r   c                   4    \ rS rSrSr      SS jrS rSrg)Flagsi  a  
The result of a checkbox group or multi-menu.  The flags should be a
list of tuples of tag, value, and description. The tag will be
the value returned if the user hits "Submit", and the description
is the bale for the enumerated type.  default is a list of all the
values (second elements in flags).  If no defaults are specified,
initially nothing will be selected.  Several items may be selected at
once.
Nc           
      <    X l         [        R                  XX4XVUS9  g Nr   )flagsr!   r   )r   r%   r   r'   r(   r)   r*   r&   s           r   r   Flags.__init__  s%     
Hy 	 	
r   c                     U(       d  / $ / nU H>  nU R                    H  u  pEnX4:X  d  M  UR                  U5          M0     [        SU-  5      e   U$ )NzInvalid Flag: %s)r   r   r   )r   
inFlagKeysoutFlags	inFlagKeyflagKeyflagValflagDescs          r   rA   Flags.coerce!  s[    I#I.2jj*('OOG, /9
 !!3i!?@@ $ r   )r   )r   r   NNNrC   r   r   r   r   r   r     s%     
r   r   c                       \ rS rSrSrg)
CheckGroupi/  r   Nr   r   r   r   r   r   r   r   r   r   /      r   r   c                       \ rS rSrSrg)
RadioGroupi3  r   Nr   r   r   r   r   r   3  r   r   r   c                       \ rS rSrS rSrg)Booleani7  c                 T    U(       d  g[        U5      R                  5       nUS;   a  gg)Nr   )nonffalse0rC   )rO   lower)r   inVallInVals      r   rA   Boolean.coerce8  s)    U!!#33r   r   N)r   r   r   r   rA   r   r   r   r   r   r   7  s    r   r   c                   $    \ rS rSrSS jrS rSrg)FileiA  Nc           
      0    [         R                  XS X4XRS9  g r   rh   )r   r%   r&   r(   r)   r*   s         r   r   File.__init__B  s    i5 	 	
r   c                 \    U(       d  U R                   (       a  g U(       a  U$ [        S5      e)NzInvalid File)r&   r   )r   files     r   rA   File.coerceG  s!    K^,,r   r   )rC   NNNr{   r   r   r   r   r   A  s    

-r   r   c                 4    [        U 5      n U S::  a  [        eU $ )Nr   )rn   ro   )xs    r   positiveIntr   P  s    AAAvHr   c                   L    \ rS rSr% SrSr\\\\\4      \	S'    SS jr
S rSrg)	DateiW  z#A date -- (year, month, day) tuple.Nr#   c                 \    [         R                  XX4XV5        X l        U(       d  SU l        g g )N)i  rC   rC   )r!   r   r&   r#   ri   s          r   r   Date.__init__\  s+     	$g(J"".D r   c                    [        U5      S:X  a  U R                  (       a  g [        [        U5      u  p#nX44S:X  a-  [        R                  " U5      (       d  [        SU-  5      eX#U4$  [        R                  U   nXE:  a  [        S5      eX#U4$ ! [         a    [        S5      ef = f! [         a    [        S5      ef = f)z(Return tuple of ints (year, month, day).)r:   r:   r:   NzInvalid date)r^      z%d was not a leap year)
tupler&   mapr   ro   r   calendarisleapmdays
IndexError)r   r   yearmonthdayr   s         r   rA   Date.coerced  s    ;,&4>>	-";5D <7"??4(( !9D!@AAC''	-NN5)E ;^,,C  	-^,,	-  	-^,,	-s   B +B+ B(+C)r&   r#   rr   )r   r   r   r   r   r#   r   r   rn   rD   r   rA   r   r   r   r   r   r   W  s0    -59NHU3S=129 UY/ r   r   c                   6    \ rS rSrSrS/SSSSS4S jrS rSrg)	Submiti{  z0Submit button or a reasonable facsimile thereof.)r   submitzSubmit formr   Nc           	      L    [         R                  U UUUUUS9  X`l        X0l        g )N)r   r(   r)   r*   )r   r   r&   reset)r   r%   r   r   r(   r)   r&   r*   s           r   r   Submit.__init__~  s3     	 	 	
 #
r   c                 ^    U R                   (       a  U(       d  g [        R                  X5      $ r
   )r&   r   rA   )r   values     r   rA   Submit.coerce  s    >>%==--r   )r&   r   r   r   r   r   r   r   {  s&    :
 55*.r   r   c                       \ rS rSrSrSrg)PresentationHinti  z 
A hint to a particular system.
r   Nr   r   r   r   r   r     r   r   r   c                   .    \ rS rSrSrS rS rSS jrSrg)	MethodSignaturei  z
A signature of a callable.
c                     Xl         g)r:   NmethodSignature)r   sigLists     r   r   MethodSignature.__init__  s    &r   c                 R    U R                    H  nUR                  U:X  d  M  Us  $    g r
   )r   r%   )r   r%   as      r   getArgumentMethodSignature.getArgument  s"    %%Avv~ &r   c                     [        XU5      $ r
   )
FormMethod)r   callabletakesRequests      r   methodMethodSignature.method  s    $,77r   r   NF)	r   r   r   r   r   r   r   r   r   r   r   r   r   r     s    '
8r   r   c                   .    \ rS rSrSrSS jrS rS rSrg)	r   i  z#A callable object with a signature.c                 (    Xl         X l        X0l        g r
   )	signaturer   r   )r   r   r   r   s       r   r   FormMethod.__init__  s    " (r   c                 @    [        U R                  R                  5      $ r
   )r   r   r   r6   s    r   getArgsFormMethod.getArgs  s    T^^3344r   c                 &    U R                   " U0 UD6$ r
   )r   )r   r   kws      r   callFormMethod.call  s    }}d)b))r   )r   r   r   Nr   )	r   r   r   r   r   r   r   r   r   r   r   r   r   r     s    -)
5*r   r   )r   r   typingr   r   r   r   r   r   r!   rF   rU   rX   r[   rb   re   rt   r}   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r      s     ' '#I # "; ";J$X $N6 8v 8v V h 4(7 (V8H 8,!=X !=H%H %P	 		 	h -8 -! 8 ! H.V .> 8 8$* *r   