3 =X/@s$ddlZddlmZddlmZmZddlmZddZddZ d d Z d d Z d dZ ddZ ddZddZddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Z d7d8Z!d9d:Z"d;d<Z#d=d>Z$d?d@Z%dS)AN)_utils) FormatErrorValidationError) iteritemsc csn|j|dsdSxXt|D]L\}}xBt|D]6\}}tj||r,x |j||||dD] }|VqTWq,WqWdS)Nobject)path schema_path)is_typerresearchdescend) validatorpatternPropertiesinstanceschemapattern subschemakverrorr!/usr/lib/python3.6/_validators.pyrs  rc cs|j|dsdSttj||}|j|dr`x|D](}x"|j||||dD] }|VqLWq2Wn| r|rd|krt|d}t|dkrd}nd}ddjtt t||djtt |f}t |Vnd }t |tj |VdS) Nr)rrZdoesZdoz&%s %s not match any of the regexes: %sz, z8Additional properties are not allowed (%s %s unexpected)) r setrZfind_additional_propertiesr sortedlenjoinmapreprr extras_msg) r ZaPrrZextrasZextrarZpatternsZverbrrradditionalPropertiess(       r ccs|j|dsdS|j|drTxxt|D](\}}x|j|||dD] }|Vq@Wq&WnBx@tt||D].\\}}}x |j||||dD] }|VqWqdWdS)Narrayr)r)rr)r enumerater zip)r itemsrrindexitemrrrrrr$1s  r$ccs|j|d s"|j|jdidr&dSt|jdg}|j|drxt||d|dD](\}}x|j|||dD] }|VqrWqXWnJ| rt|t|jdgkrd}t|tj|t|jdgdVdS)Nr!r$r)start)rz3Additional items are not allowed (%s %s unexpected))r getrr"r rrr)r ZaIrrZ len_itemsr%r&rrrradditionalItemsAs r)ccsR|j|dsdS|jddr*||k}d}n ||k}d}|rNtd|||fVdS)NnumberZexclusiveMinimumFzless than or equal toz less thanz%r is %s the minimum of %r)r r(r)r minimumrrfailedcmprrrr+Us  r+ccsR|j|dsdS|jddr*||k}d}n ||k}d}|rNtd|||fVdS)Nr*ZexclusiveMaximumFzgreater than or equal toz greater thanz%r is %s the maximum of %r)r r(r)r maximumrrr,r-rrrr.fs  r.ccsR|j|dsdSt|tr0||}t||k}n||}|rNtd||fVdS)Nr*z%r is not a multiple of %r)r isinstancefloatintr)r ZdBrrZquotientr,rrr multipleOfws  r2ccs,|j|dr(t||kr(td|fVdS)Nr!z%r is too short)r rr)r mIrrrrrminItemssr4ccs,|j|dr(t||kr(td|fVdS)Nr!z%r is too long)r rr)r r3rrrrrmaxItemssr5ccs0|r,|j|dr,tj| r,td|fVdS)Nr!z%r has non-unique elements)r rZuniqr)r ZuIrrrrr uniqueItemss  r6ccs0|j|dr,tj|| r,td||fVdS)Nstringz%r does not match %r)r r r r)r Zpatrnrrrrrrs rccsV|jdk rRy|jj||Wn4tk rP}zt|j|jdVWYdd}~XnXdS)N)cause)Zformat_checkerZcheckrrmessager8)r formatrrrrrrr:s  r:ccs,|j|dr(t||kr(td|fVdS)Nr7z%r is too short)r rr)r mLrrrrr minLengthsr<ccs,|j|dr(t||kr(td|fVdS)Nr7z%r is too long)r rr)r r;rrrrr maxLengthsr=ccs|j|dsdSx~t|D]r\}}||kr,q|j|drZxR|j|||dD] }|VqJWqtj|}x&|D]}||krjtd||fVqjWqWdS)Nr)rz%r is a dependency of %r)r rr r ensure_listr)r dependenciesrrpropertyZ dependencyrrrrr?s     r?ccs||krtd||fVdS)Nz%r is not one of %r)r)r ZenumsrrrrrenumsrAc cst|jdd}|dkrL|jj|"}x|j||D] }|Vq2WWdQRXnJ|jj|\}}|jj|z x|j||D] }|VqxWWd|jjXdS)Nresolve)getattrZresolverZ resolvingr rBZ push_scopeZ pop_scope)r refrrrBZresolvedrZscoperrrrDs rDccstj|}g}xzt|D]X\}}|dkr,dS|j|dr`t|j|||d}|sTdS|j|q|j||rdSqWttj|||dVdS)Nanyr)r)context) rr>r"r listr extendr types_msg)r typesrr all_errorsr%typeerrorsrrr type_draft3s    rNccs|j|dsdSxt|D]\}}||krRxv|j|||||dD] }|VqBWq|jddrtd|}|jd|d||d|jj||jj |dg|VqWdS)Nr)rrrequiredFz%r is a required property)r Zvalidator_valuerr) r rr r(rZ_setr appendleftrrH)r propertiesrrr@rrrrrproperties_draft3s(      rRccs<x6tj|D](}|j|d|gir td||fVq WdS)NrLz%r is disallowed for %r)rr>is_validr)r ZdisallowrrZ disallowedrrrdisallow_draft3 srTccsf|j|dr,x|j||D] }|VqWdSx4t|D](\}}x|j|||dD] }|VqPWq6WdS)Nr)r)r r r")r Zextendsrrrr%rrrrextends_draft3s  rUc#s8tj|}tfdd|Ds4ttj|VdS)Nc3s|]}j|VqdS)N)r ).0rL)rr rr "sztype_draft4..)rr>rErrI)r rJrrr)rr r type_draft4s rXccsX|j|dsdSxBt|D]6\}}||krx$|j|||||dD] }|VqBWqWdS)Nr)rr)r rr )r rQrrr@rrrrrproperties_draft4&s  rYccs8|j|dsdSx"|D]}||krtd|VqWdS)Nrz%r is a required property)r r)r rOrrr@rrrrequired_draft45s   rZccs,|j|dr(t||kr(td|fVdS)Nrz"%r does not have enough properties)r rr)r mPrrrrrminProperties_draft4=sr\ccs<|j|dsdS|j|dr8t||kr8td|fVdS)Nrz%r has too many properties)r rr)r r[rrrrrmaxProperties_draft4Ds r]ccs:x4t|D](\}}x|j|||dD] }|Vq$Wq WdS)N)r)r"r )r ZallOfrrr%rrrrr allOf_draft4Ksr^c #st|}g}xL|D]0\}}tj||d}|s8|} P|j|qWtdf|dVfdd|D} | r| j| djdd| D} td | fVdS) N)rz.%r is not valid under any of the given schemas)rFcs g|]\}}j|r|qSr)rS)rVis)rr rr `sz oneOf_draft4..z, css|]}t|VqdS)N)r)rVrrrrrWcszoneOf_draft4..z%r is valid under each of %s)r"rGr rHrappendr) r ZoneOfrrZ subschemasrKr%rerrsZ first_validZ more_validZreprsr)rr r oneOf_draft4Qs"  rdccsVg}xLt|D],\}}t|j|||d}|s0P|j|qWtd|f|dVdS)N)rz.%r is not valid under any of the given schemas)rF)r"rGr rHr)r ZanyOfrrrKr%rrcrrr anyOf_draft4isreccs"|j||rtd||fVdS)Nz%r is not allowed for %r)rSr)r Z not_schemarrrrr not_draft4ws rf)&r Z jsonschemarZjsonschema.exceptionsrrZjsonschema.compatrrr r$r)r+r.r2r4r5r6rr:r<r=r?rArDrNrRrTrUrXrYrZr\r]r^rdrerfrrrrsB