ϪfJ/dZddlZddlmZmZmZGddeZGddeZGdd Z Gd d e Z Gd d e Z Gdde Z Gdde Z Gdde ZGdde ZGddeZGdde ZGdde ZGdde ZGddeZGd d!eZGd"d#e ZGd$d%e Zd&ZGd'd(e ZGd)d*eZGd+d,ZGd-d.ZGd/d0Zy)1z Form-based method objects. This module contains support for descriptive method signatures that can be used to format methods. N)AnyOptionalTupleceZdZdZdZy) FormExceptionz*An error occurred calling the form method.c>tj|g|||_yN) Exception__init__ descriptions)selfargskwargss ;/usr/lib/python3/dist-packages/twisted/python/formmethod.pyr zFormException.__init__s4'$'"N)__name__ __module__ __qualname____doc__r rrrrs 4#rrceZdZdZy) InputErrorz, An error occurred with some input. NrrrrrrrrrrrcJeZdZUdZdZeed< d dZdZd dZ dZ dZ d Z y) ArgumentzBase class for form arguments.NdefaultDefaultc|||_||_| |j}||_||_||_|si}||_yr )name allowNonerdefault shortDesclongDeschints)r rr!r"r#r$r s rr zArgument.__init__%sF " ?))G "  E rc :|jj|yr )r$update)r rs raddHintszArgument.addHints3s &!rc:|jj||Sr )r$get)r rr!s rgetHintzArgument.getHint6szz~~dG,,rcR|jxs|jjSr )r"r capitalizer s rgetShortDescriptionzArgument.getShortDescription9s~~7!5!5!77rc"|jxsdS)N)r#r-s rgetLongDescriptionzArgument.getLongDescription<s}}""rctd)z(Convert the value to the correct format.zimplement in subclass)NotImplementedErrorr vals rcoercezArgument.coerce?s!"9::r)NNNNr ) rrrrrr__annotations__r r'r*r.r1r6rrrrrs6(NCXY "-8#;rrcDeZdZUdZdZeed<dZdZ ddZ dZ y) StringzA single string.r0rrNc Xtj|||||||||_||_y)N)r!r"r#r$r )rr minmax) r rr!r"r#r$r r<r=s rr zString.__init__Ks<     rct|}t||jkrtd|jz|j0t||jkDrtd|jzt|S)N)Value must be at least %s characters long(Value must be at most %s characters long)strlenr<rr=)r r5ss rr6z String.coercebsg H q6DHH H488ST T 88 CFTXX$5G$((RS S3xr)NNNNr7rN) rrrrrrAr8r<r=r r6rrrr:r:Ds:NC C C  .rr:ceZdZdZy)TextzA long string.NrrrrrErEksrrEceZdZdZy)Passwordz-A string which should be obscured when input.NrrrrrGrGos7rrGceZdZdZdZy)VerifiedPasswordzCA string that should be obscured when input and needs verification.cBt|dk7s |d|dk7r tdt|d}t||jkrtd|jz|j0t||jkDrtd|jz|S)Nrr7z%Please enter the same password twice.r?r@)rBrrAr<r=)r valsrCs rr6zVerifiedPassword.coercevs t9>T!WQ/DE E QL q6DHH H488ST T 88 CFTXX$5G$((RS SrN)rrrrr6rrrrIrIss MrrIceZdZdZy)HiddenzSA string which is not displayed. The passed default is used as the value. NrrrrrNrNsrrNc6eZdZUdZdZeeed< ddZdZ y)IntegerzA single integer.Nrc :tj|||||||yr rr r rr r!r"r#r$s rr zInteger.__init__ $gy(E9Urc|js |jry t|S#t$rt dj |wxYw)Nz5{} is not valid, please enter a whole number, e.g. 10)stripr int ValueErrorrformatr4s rr6zInteger.coercesMyy{t~~ s8O JQQRUV  s *$Ar7NNNN) rrrrrrrWr8r r6rrrrPrPs%$(NHSM(UYVrrPc$eZdZ ddZdZy) IntegerRangeNc X||_||_tj|||||||y)N)r r!r"r#r$)r<r=rPr ) r rr<r=r r!r"r#r$s rr zIntegerRange.__init__s:    rc(tj||}|jr|dk(r|S||jkr%t dj ||j||j kDr%t dj ||j |S)Nz/Value {} is too small, it should be at least {}z.Value {} is too large, it should be at most {})rPr6r r<rrYr=)r r5results rr6zIntegerRange.coercesc* >>fnM DHH AHHDHH  DHH @GGDHH   rrZrrrr r6rrrr\r\s  .rr\c2eZdZUdZeeed< ddZdZy)FloatNrc :tj|||||||yr rRrSs rr zFloat.__init__rTrc|js |jry t|S#t$rt d|zwxYw)NzInvalid float: %s)rVr floatrXrr4s rr6z Float.coercesCyy{t~~ 8:  80367 7 8s *ArZ) rrrrrrer8r r6rrrrbrbs"&*NHUO*UYV8rrbc*eZdZdZggddddfdZdZy)Choicea 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. Nr7c ||_|r|s|j|ddtj|||||||y)Nrr7r )choicesappendrr )r rrjr!r"r#r$r s rr zChoice.__init__sF 7 NN71:a= ) $Hey  rcZ|jD]\}}}||k(s |cStd|z)NzInvalid Choice: %s)rjr)r inIdentidentr5descs rr6z Choice.coerces< $  = E3  =1G;< |s |jry|r|Std)Nz Invalid File)r r)r files rr6z File.coerceGs! K^, ,r)r7NNNr`rrrrrAs  -rrc2t|}|dkrt|S)Nr)rWrX)xs r positiveIntrPs AAAv HrcBeZdZUdZdZeeeeefed< ddZ dZ y)Datez#A date -- (year, month, day) tuple.NrcZtj||||||||_|sd|_yy)N)ir7r7)rr r rrSs rr z Date.__init__\s3 $gy(EJ"".D rcrt|dk(r |jry tt|\}}}||fdk(r(t j|st d|z|||fS t j|}||kDr t d|||fS#t$r t dwxYw#t$r t dwxYw)z(Return tuple of ints (year, month, day).)r0r0r0Nz Invalid date)rKz%d was not a leap year) tupler maprrXrcalendarisleapmdays IndexError)r ryearmonthdayrs rr6z Date.coerceds ;, &4>> -";5 D% 3<7 "??4( !9D!@AAUC'' -NN5)E ;^, ,UC -^, , - -^, , -sB !B! B!B6rZ) rrrrrrrrWr8r r6rrrrrWs0-59NHU3S=129UY/ rrc,eZdZdZdgdddddfdZdZy)Submitz0Submit button or a reasonable facsimile thereof.)rsubmitz Submit formrNcVtj||||||||_||_y)N)rjr"r#r$)rgr r reset)r rrjrr"r#r r$s rr zSubmit.__init__~s7     # rcL|jr|sytj||Sr )r rgr6)r values rr6z Submit.coerces >>%==u- -rrprrrrr{s&: 55*.rrceZdZdZy)PresentationHintz( A hint to a particular system. Nrrrrrrrrrc$eZdZdZdZdZddZy)MethodSignaturez$ A signature of a callable. c||_y)r0N)methodSignature)r sigLists rr zMethodSignature.__init__s &rcL|jD]}|j|k(s|cSyr )rr)r ras r getArgumentzMethodSignature.getArguments'%% Avv~ rct|||Sr ) FormMethod)r callable takesRequests rmethodzMethodSignature.methods$,77rNF)rrrrr rrrrrrrs' 8rrc$eZdZdZddZdZdZy)rz#A callable object with a signature.c.||_||_||_yr ) signaturerr)r rrrs rr zFormMethod.__init__s"  (rc@t|jjSr )rrrr-s rgetArgszFormMethod.getArgssT^^3344rc&|j|i|Sr )r)r rkws rcallzFormMethod.callst}}d)b))rNr)rrrrr rrrrrrrs-) 5*rr)rrtypingrrrr rrrr:rErGrIrNrPr\rbrgrrr~rrrrrrrrrrrrrs  ''#I# ";";J$X$N68v8 v Vh4(7(V8H8,!=X!=H%H%P    h -8 - ! 8! H.V.> 88$ * *r