B ÉpSe·-ã@sLddlZddlmZmZmZmZmZmZmZddl m Z m Z ddl m Z dd„Zdd„Zd d „Zd d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Z d+d,„Z!d-d.„Z"d/d0„Z#d1d2„Z$d3d4„Z%d5d6„Z&d7d8„Z'd9d:„Z(d;d<„Z)d=d>„Z*d?d@„Z+dAdB„Z,dCdD„Z-dS)EéN)Ú ensure_listÚequalÚ extras_msgÚfind_additional_propertiesÚ types_msgÚunboolÚuniq)Ú FormatErrorÚValidationError)Ú iteritemsc csn| |d¡sdSxXt|ƒD]L\}}xBt|ƒD]6\}}t ||¡r,x |j||||d�D] }|VqTWq,WqWdS)NÚobject)ÚpathÚ schema_path)Úis_typer ÚreÚsearchÚdescend) Ú validatorÚpatternPropertiesÚinstanceÚschemaÚpatternÚ subschemaÚkÚvÚerror©rúG/opt/alt/python37/lib/python3.7/site-packages/jsonschema/_validators.pyrs  rccs@| |d¡sdSx*|D]"}x|j||d�D] }|Vq*WqWdS)Nr )rr)rr)rÚ propertyNamesrrÚpropertyrrrrrs   rc csà| |d¡sdStt||ƒƒ}| |d¡r^x°|D](}x"|j||||d�D] }|VqJWq0Wn~|sÜ|rÜd|krÆt|dƒ}t|ƒdkrŒd}nd}dd ttt|ƒƒ¡|d tt|ƒ¡f}t |ƒVnd }t |t |ƒƒVdS) Nr )r réZdoesÚdoz&%s %s not match any of the regexes: %sz, z8Additional properties are not allowed (%s %s unexpected)) rÚsetrrÚsortedÚlenÚjoinÚmapÚreprr r) rZaPrrÚextrasÚextrarÚpatternsZverbrrrÚadditionalProperties)s(      r+ccsš| |d¡sdS| |d¡r`xxtt|ƒ|ƒD].\\}}}x |j||||d�D] }|VqLWq,Wn6x4t|ƒD](\}}x|j|||d�D] }|Vq„WqjWdS)NÚarray)r r)r )rÚzipÚ enumerater)rÚitemsrrÚindexÚitemrrrrrr/Es  r/c csÎ| |d¡r | | di¡d¡r$dSt| dg¡ƒ}| |d¡r„xˆt||d…|d�D](\}}x|j|||d�D] }|VqpWqVWnF|sÊt|ƒt| dg¡ƒkrÊd}t|t|t| dg¡ƒd…ƒƒVdS)Nr,r/r )Ústart)r z3Additional items are not allowed (%s %s unexpected))rÚgetr$r.rr r)rZaIrrZ len_itemsr0r1rrrrÚadditionalItemsUs  r4ccst||ƒstd|fƒVdS)Nz%r was expected)rr )rÚconstrrrrrr5is r5c#s<ˆ |d¡sdSt‡‡fdd„|Dƒƒs8td|fƒVdS)Nr,c3s|]}ˆ |ˆ¡VqdS)N)Úis_valid)Ú.0Úelement)Úcontainsrrrú rszcontains..z+None of %r are valid under the given schema)rÚanyr )rr9rrr)r9rrr9ns  r9ccs.| |d¡sdS||kr*td||fƒVdS)NÚnumberz-%r is less than or equal to the minimum of %r)rr )rÚminimumrrrrrÚexclusiveMinimumxs  r>ccs.| |d¡sdS||kr*td||fƒVdS)Nr<z0%r is greater than or equal to the maximum of %r)rr )rÚmaximumrrrrrÚexclusiveMaximum„s  r@ccs.| |d¡sdS||kr*td||fƒVdS)Nr<z!%r is less than the minimum of %r)rr )rr=rrrrrr=�s  r=ccs.| |d¡sdS||kr*td||fƒVdS)Nr<z$%r is greater than the maximum of %r)rr )rr?rrrrrr?šs  r?ccsR| |d¡sdSt|tƒr0||}t|ƒ|k}n||}|rNtd||fƒVdS)Nr<z%r is not a multiple of %r)rÚ isinstanceÚfloatÚintr )rZdBrrZquotientÚfailedrrrÚ multipleOf¤s  rEccs,| |d¡r(t|ƒ|kr(td|fƒVdS)Nr,z%r is too short)rr$r )rÚmIrrrrrÚminItems²srGccs,| |d¡r(t|ƒ|kr(td|fƒVdS)Nr,z%r is too long)rr$r )rrFrrrrrÚmaxItems·srHccs,|r(| |d¡r(t|ƒs(td|fƒVdS)Nr,z%r has non-unique elements)rrr )rZuIrrrrrÚ uniqueItems¼s rIccs.| |d¡r*t ||¡s*td||fƒVdS)NÚstringz%r does not match %r)rrrr )rZpatrnrrrrrrÅs  rc csV|jdk rRy|j ||¡Wn4tk rP}zt|j|jd�VWdd}~XYnXdS)N)Úcause)Zformat_checkerÚcheckr r ÚmessagerK)rÚformatrrrrrrrNÍs  rNccs,| |d¡r(t|ƒ|kr(td|fƒVdS)NrJz%r is too short)rr$r )rÚmLrrrrrÚ minLengthÕsrPccs,| |d¡r(t|ƒ|kr(td|fƒVdS)NrJz%r is too long)rr$r )rrOrrrrrÚ maxLengthÚsrQc csŽ| |d¡sdSxxt|ƒD]l\}}||kr,q| |d¡rfxL|D]"}||kr>d}t|||fƒVq>Wqx|j|||d�D] }|VqxWqWdS)Nr r,z%r is a dependency of %r)r)rr r r) rÚ dependenciesrrrZ dependencyÚeachrMrrrrrRßs   rRc#s`|dks|dkrBt|ƒ‰t‡fdd„|Dƒƒr\td||fƒVn||kr\td||fƒVdS)Nrr c3s|]}ˆt|ƒkVqdS)N)r)r7rS)Úunbooledrrr:öszenum..z%r is not one of %r)rÚallr )rZenumsrrr)rTrÚenumós rVc csšt|jddƒ}|dkrL|j |¡�"}x| ||¡D] }|Vq2WWdQRXnJ|j |¡\}}|j |¡z x| ||¡D] }|VqxWWd|j ¡XdS)NÚresolve)ÚgetattrZresolverZ resolvingrrWZ push_scopeZ pop_scope)rÚrefrrrWZresolvedrZscoperrrrYüs rYc#s4t|ƒ}t‡‡fdd„|Dƒƒs0ttˆ|ƒƒVdS)Nc3s|]}ˆ ˆ|¡VqdS)N)r)r7Útype)rrrrr:sztype..)rr;r r)rÚtypesrrr)rrrrZ srZccsX| |d¡sdSxBt|ƒD]6\}}||krx$|j|||||d�D] }|VqBWqWdS)Nr )r r)rr r)rÚ propertiesrrrrrrrrr\s  r\ccs8| |d¡sdSx"|D]}||krtd|ƒVqWdS)Nr z%r is a required property)rr )rÚrequiredrrrrrrr]#s   r]ccs,| |d¡r(t|ƒ|kr(td|fƒVdS)Nr z"%r does not have enough properties)rr$r )rÚmPrrrrrÚ minProperties+sr_ccs<| |d¡sdS| |d¡r8t|ƒ|kr8td|fƒVdS)Nr z%r has too many properties)rr$r )rr^rrrrrÚ maxProperties2s r`ccs:x4t|ƒD](\}}x|j|||d�D] }|Vq$Wq WdS)N)r)r.r)rÚallOfrrr0rrrrrra9sraccsVg}xLt|ƒD],\}}t|j|||d�ƒ}|s0P| |¡qWtd|f|d�VdS)N)rz.%r is not valid under any of the given schemas)Úcontext)r.ÚlistrÚextendr )rÚanyOfrrÚ all_errorsr0rÚerrsrrrre?srec #s¦t|ƒ}g}xL|D]0\}}tˆjˆ||d�ƒ}|s8|} P| |¡qWtdˆf|d�V‡‡fdd„|Dƒ} | r¢|  | ¡d dd„| Dƒ¡} td ˆ| fƒVdS) N)rz.%r is not valid under any of the given schemas)rbcs g|]\}}ˆ ˆ|¡r|‘qSr)r6)r7ÚiÚs)rrrrú \szoneOf..z, css|]}t|ƒVqdS)N)r')r7rrrrr:_szoneOf..z%r is valid under each of %s)r.rcrrdr Úappendr%) rÚoneOfrrZ subschemasrfr0rrgZ first_validZ more_validZreprsr)rrrrlMs"  rlccs"| ||¡rtd||fƒVdS)Nz%r is not allowed for %r)r6r )rZ not_schemarrrrrÚnot_es rmccsr| ||¡r>d|krn|d}xP|j||dd�D] }|Vq.Wn0d|krn|d}x|j||dd�D] }|Vq`WdS)NÚthen)rÚelse)r6r)rZ if_schemarrrnrZelse_rrrÚif_ls  rp).rZjsonschema._utilsrrrrrrrZjsonschema.exceptionsr r Zjsonschema.compatr rrr+r/r4r5r9r>r@r=r?rErGrHrIrrNrPrQrRrVrYrZr\r]r_r`rarerlrmrprrrrÚsF$