`d(ddlmZmZmZddlmZddlZddlZddlZddl Z e jdk\rddl m Z nddl Z GddeZGdd eZd Zd Zd Zd ZdZdZdZdZeefdZdZdZdZy))MappingMutableMappingSequence)urlsplitN) ) resourcesc@eZdZdZdZdZdZdZdZdZ dZ d Z y ) URIDictz8 Dictionary which uses normalized URIs as keys. c4t|jSN)rgeturlselfuris 3/usr/lib/python3/dist-packages/jsonschema/_utils.py normalizezURIDict.normalizes}##%%cZt|_|jj|i|yr )dictstoreupdate)rargskwargss r__init__zURIDict.__init__s$V  4*6*rc>|j|j|Sr rrrs r __getitem__zURIDict.__getitem__szz$..-..rc@||j|j|<yr r)rrvalues r __setitem__zURIDict.__setitem__s*/ 4>>#&'rc<|j|j|=yr rrs r __delitem__zURIDict.__delitem__!s JJt~~c* +rc,t|jSr )iterrrs r__iter__zURIDict.__iter__$DJJrc,t|jSr )lenrr&s r__len__zURIDict.__len__'s4::rc,t|jSr )reprrr&s r__repr__zURIDict.__repr__*r(rN) __name__ __module__ __qualname____doc__rrrr!r#r'r+r.rrr r s/&+/0,  rr ceZdZdZdZy)UnsetzG An as-of-yet unset attribute or unprovided default parameter. cy)Nzr3r&s rr.zUnset.__repr__3srN)r/r0r1r2r.r3rrr5r5.s rr5ctjtjd|d}|j d}t j |S)zC Load a schema from ./schemas/``name``.json and return it. zschemas/z.jsonzutf-8)encoding)r files __package__joinpath read_textjsonloads)namepathdatas r load_schemarB7sE ??; ' 0 08D61G HD >>7> +D ::d rcF|s|S|ddjd|DdS)aA Construct a single string containing indexing operations for the indices. For example for a container ``bar``, [1, 2, "foo"] -> bar[1][2]["foo"] Arguments: container (str): A word to use for the thing being indexed indices (sequence): The indices to format. [z][c32K|]}t|ywr r-).0indexs r z"format_as_index..Ts#EEDK#E])join) containerindicess rformat_as_indexrOAs0" [$))#EW#EEFa HHrc#K|jdi}dj|jdi}|D]$}||vs|rtj||r!|&yw)z Return the set of additional properties for the given ``instance``. Weeds out properties that should have been validated by ``properties`` and / or ``patternProperties``. Assumes ``instance`` is dict-like already. properties|patternPropertiesN)getrLresearch)instanceschemarQpatternspropertys rfind_additional_propertiesr[WsaL"-Jxx #6;.ss=UT%[=rJ)r*rLsorted)extrasverbs r extras_msgrejs8  6{a 99=fVn= =t CCrc,t|tr|gS|S)z] Wrap ``thing`` in a list if it's a single str. Otherwise, return it unchanged. ) isinstancestr)things r ensure_listrjvs%w Lrcxt|tk7rytfd|jDS)zI Check if two mappings are equal using the semantics of `equal`. Fc3NK|]\}}|vxrt||ywr equal)rGkeyr twos rrIz!_mapping_equal..s4 C s -uUCH--s"%)r*allitemsonerps `r_mapping_equalrus8 3x3s8 ))+ rcjt|t|k7rytdt||DS)zJ Check if two sequences are equal using the semantics of `equal`. Fc3:K|]\}}t||ywr rm)rGijs rrIz"_sequence_equal..s5tq!uQ{5s)r*rqziprss r_sequence_equalr{s. 3x3s8 5s3}5 55rc*t|tst|tr||k(St|trt|tr t||St|trt|tr t ||St |t |k(S)z Check if two things are equal evading some Python type hierarchy semantics. Specifically in JSON Schema, evade `bool` inheriting from `int`, recursing into sequences to do the same. )rgrhrr{rruunboolrss rrnrnst#sz#s3cz#x ZX%>sC((#wJsG$<c3'' #;&+ %%rc|dur|S|dur|S|S)zH A hack to make True and 1 and False and 0 unique for ``uniq``. TFr3)elementtruefalses rr}r}s" $ E  Nrc@ td|D}tj|dd}t||D]\}}t ||sy y#t t f$r?g}|D]5}t|}|D]}t ||sYy|j|7YywxYw)z Check if all of a container's elements are unique. Tries to rely on the container being recursively sortable, or otherwise falls back on (slow) brute force. c32K|]}t|ywr )r})rGrxs rrIzuniq..s3AfQi3rJr]NFT) rb itertoolsislicerzrnNotImplementedError TypeErrorr}append)rMsortslicedrxryseenes runiqrs333!!$40f% DAqQ{    +  Aq A !A;  ! KKN   s*AA A A2BBBBc |j|drgSg}d|vrttdt|Sd|vrg|jj |d\}}|jj | |t|||z }|jjd|vr$|ttdt|dz }d|vrf|j|dj|r+|t|||dz }d|vr+|t|||dz }nd |vr|t|||d z }d D]P}||vst|D];\}}|j||j|s+|j|=Rd D]?}||vs||D]0} t|j|| } | r!|t||| z }2A|S#|jjwxYw) z Get all indexes of items that get evaluated under the current schema Covers all keywords related to unevaluatedItems: items, prefixItems, if, then, else, contains, unevaluatedItems, allOf, oneOf, anyOf booleanrrr$ref prefixItemsifrXthenelse)containsunevaluatedItemsallOfoneOfanyOf)is_typelistranger*resolverresolve push_scope%find_evaluated_item_indexes_by_schema pop_scopeevolveis_valid enumeraterdescend) validatorrWrXevaluated_indexesscoperesolvedkeywordkv subschemaerrss rrrsF+ &E!S]+,, #,,44VF^Dx%%e, + !F8X"      ( ( *T%3vm/D+E"FGG v~   6$<  0 9 9( C !F8VD\"  !%Jx&!!%Jx&!40 f !(+ 01##6'?#;DDQG%,,Q/ 00 / f #G_  I--h BC%)N!8Y*%  G    ( ( *s :GG-c|j|drgSg}d|vrg|jj|d\}}|jj| |t |||z }|jj dD]}||vs|j||drP|j D]=\}}|j||j||is-|j|?|j||ds||j D]@\}} ||vs |j| j||s0|j|Bd|vr|j D]o\}}|dj D]T\} } tj| |s|j|dj||isD|j|Vqd|vr0|dj D]\}} ||vr |t ||| z }dD]?}||vs||D]0} t|j|| } | r!|t ||| z }2Ad |vrg|j|d j|r,|t |||d z }d |vr|t |||d z }|Sd |vr|t |||d z }|S#|jj wxYw) a Get all keys of items that get evaluated under the current schema Covers all keywords related to unevaluatedProperties: properties, additionalProperties, unevaluatedProperties, patternProperties, dependentSchemas, allOf, oneOf, anyOf, if, then, else rr)rQadditionalPropertiesunevaluatedPropertiesrobjectrSdependentSchemasrrrr)rrrr&find_evaluated_property_keys_by_schemarrrrrrrUrVrr) rrWrXevaluated_keysrrrrZr rpattern_rs rrr s+ N #,,44VF^Dx%%e, + D8X N    ( ( *8 f   )<'/~~'78OHe ''vg'?HH!5)'--h7 8   (;+1'?+@+@+B8'Hi8+ 0@0@(1A1hx1213'--h7 88$f$'~~/ 4OHe$%89??A 4 99Wh/I4D4D!"565E5(He,-5.#))(3  4 4V##)*<#=#C#C#E  Hix' D8Y N / f #G_  I--h BC"&L!8Y'N  v~   6$<  0 9 9( C D8VD\ N"Hx#  "Hx# y    ( ( *s K K&)collections.abcrrr urllib.parserrr=rUsys version_info importlibr importlib_resourcesr rr5rBrOr[rerjrur{rnr}rrrr3rrrs==! v#+ n >FI,& D  6 &   8:zQr