rc(ddlmZmZmZddlmZddlZddlZddlZddl Z e j dkrddl m Z nddl Z GddeZGdd eZd Zd Zd Zd ZdZdZdZdZeefdZdZdZdZdS))MappingMutableMappingSequence)urlsplitN) ) resourcescBeZdZdZdZdZdZdZdZdZ dZ d Z d S) URIDictz8 Dictionary which uses normalized URIs as keys. cDt|SN)rgeturlselfuris 3/usr/lib/python3/dist-packages/jsonschema/_utils.py normalizezURIDict.normalizes}}##%%%cPt|_|jj|i|dSr )dictstoreupdate)rargskwargss r__init__zURIDict.__init__s-VV  4*6*****rcB|j||Sr rrrs r __getitem__zURIDict.__getitem__sz$..--..rc@||j||<dSr r)rrvalues r __setitem__zURIDict.__setitem__s */ 4>>#&&'''rc<|j||=dSr rrs r __delitem__zURIDict.__delitem__!s Jt~~c** + + +rc*t|jSr )iterrrs r__iter__zURIDict.__iter__$DJrc*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&&&+++///000,,,        rr ceZdZdZdZdS)UnsetzG An as-of-yet unset attribute or unprovided default parameter. cdS)Nzr3r&s rr.zUnset.__repr__3syrN)r/r0r1r2r.r3rrr5r5.s-rr5ctjtd|d}|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_schemarB7sP ?; ' ' 0 01GD1G1G1G H HD >>7> + +D :d  rcT|s|S|ddd|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][c34K|]}t|VdSr r-).0indexs r z"format_as_index..Ts(#E#EEDKK#E#E#E#E#E#Er])join) containerindicess rformat_as_indexrNAsD"  H H$))#E#EW#E#E#EEE H H HHrc#K|di}d|di}|D]"}||vr|rtj||r|V#dS)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)getrKresearch)instanceschemarPpatternspropertys rfind_additional_propertiesrZWsL"--Jxx #6;;<.ss(==UT%[[======r)r*rKsorted)extrasverbs r extras_msgrdjsM  6{{a 99==fVnn=== = =t CCrc6t|tr|gS|S)z] Wrap ``thing`` in a list if it's a single str. Otherwise, return it unchanged. ) isinstancestr)things r ensure_listrivs"%w Lrct|tkrdStfd|DS)zI Check if two mappings are equal using the semantics of `equal`. Fc3RK|]!\}}|vot||V"dSr equal)rGkeyr twos rrIz!_mapping_equal..sR C s -uUCH--r)r*allitemsoneros `r_mapping_equalrtsa 3xx3s88u ))++  rct|t|krdStdt||DS)zJ Check if two sequences are equal using the semantics of `equal`. Fc3<K|]\}}t||VdSr rl)rGijs rrIz"_sequence_equal..s.55tq!uQ{{555555r)r*rpziprrs r_sequence_equalrzsE 3xx3s88u 55s3}}555 5 55rct|tst|tr||kSt|tr%t|trt||St|tr%t|trt ||St |t |kS)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. )rfrgrrzrrtunboolrrs rrmrms#sz#s33cz#x  )ZX%>%>)sC(((#w(JsG$<$<(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   Nrcr td|D}tj|dd}t||D]\}}t ||rdSn\#t t f$rHg}|D]@}t|}|D]}t ||rYdS||AYnwxYwdS)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. c34K|]}t|VdSr )r|)rGrws rrIzuniq..s(33AfQii333333rr\NFT) ra itertoolsisliceryrmNotImplementedError TypeErrorr|append)rLsortslicedrwrxseenes runiqrs 3333333!$400f%%  DAqQ{{ uu    +     Aq A ! !A;;! 5555! KKNNNN    4sAAArs==========!!!!!! v#######++++     n   >FIII,& D D D      666 & & &      8:::zQQQQQr