a kiÅ]0ã@s¼ddlZddlZddlZddlZddlmZmZmZGdd„deƒZGdd„de ƒZ dd„Z dd d „Z d d „Z dd„Zdd„Zdd„Zdd„Zdd„Zdd„Ze ƒe ƒfdd„Zdd„ZdS)éN)ÚMutableMappingÚ str_typesÚurlsplitc@sPeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dS)ÚURIDictz8 Dictionary which uses normalized URIs as keys. cCs t|ƒ ¡S©N)rÚgeturl©ÚselfÚuri©r ú5/usr/lib/python3.9/site-packages/jsonschema/_utils.pyÚ normalizeszURIDict.normalizecOstƒ|_|jj|i|¤ŽdSr)ÚdictÚstoreÚupdate)r ÚargsÚkwargsr r r Ú__init__szURIDict.__init__cCs|j| |¡Sr©rr rr r r Ú __getitem__szURIDict.__getitem__cCs||j| |¡<dSrr)r r Úvaluer r r Ú __setitem__szURIDict.__setitem__cCs|j| |¡=dSrrrr r r Ú __delitem__szURIDict.__delitem__cCs t|jƒSr)Úiterr©r r r r Ú__iter__szURIDict.__iter__cCs t|jƒSr)Úlenrrr r r Ú__len__!szURIDict.__len__cCs t|jƒSr)Úreprrrr r r Ú__repr__$szURIDict.__repr__N) Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrrrrrr r r r r src@seZdZdZdd„ZdS)ÚUnsetzG An as-of-yet unset attribute or unprovided default parameter. cCsdS)Nzr rr r r r-szUnset.__repr__N)r r!r"r#rr r r r r$(sr$cCs"t dd |¡¡}t | d¡¡S)zC Load a schema from ./schemas/``name``.json and return it. Z jsonschemazschemas/{0}.jsonzutf-8)ÚpkgutilÚget_dataÚformatÚjsonÚloadsÚdecode)ÚnameÚdatar r r Ú load_schema1sr-écsd ‡fdd„| ¡Dƒ¡S)z> A dumb version of `textwrap.indent` from Python 3.3. Ú c3s|]}ddˆ|VqdS)ú éNr )Ú.0Úline©Útimesr r Ú ?ózindent..)ÚjoinÚ splitlines)Ústringr5r r4r Úindent:sr;cCs |sdSdd dd„|Dƒ¡S)zÕ Construct a single string containing indexing operations for the indices. For example, [1, 2, "foo"] -> [1][2]["foo"] Arguments: indices (sequence): The indices to format. Úz[%s]z][css|]}t|ƒVqdSr©r)r2Úindexr r r r6Qr7z"format_as_index..)r8)Úindicesr r r Úformat_as_indexBs r@ccsL| di¡}d | di¡¡}|D]$}||vr"|r@t ||¡r@q"|Vq"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ú|ZpatternPropertiesN)Úgetr8ÚreÚsearch)ÚinstanceZschemarAÚpatternsÚpropertyr r r Úfind_additional_propertiesTs rIcCs.t|ƒdkrd}nd}d dd„|Dƒ¡|fS)z@ Create an error message for extra items or properties. r.ZwasZwereú, css|]}t|ƒVqdSrr=)r2Zextrar r r r6pr7zextras_msg..)rr8)ÚextrasZverbr r r Ú extras_msggs rLc CsXg}|D]<}z| t|dƒ¡WqtyB| t|ƒ¡Yq0qd|d |¡fS)a+ Create an error message for a failure to match the given types. If the ``instance`` is an object and contains a ``name`` property, it will be considered to be a description of that object and used as its type. Otherwise the message is simply the reprs of the given ``types``. r+z%r is not of type %srJ)ÚappendrÚ Exceptionr8)rFÚtypesZreprsÚtyper r r Ú types_msgss  rQcCsLtƒ}t|tƒs|f}|D](}t|tƒr8| t|ƒ¡q| |¡qt|ƒS)zâ isinstance() can accept a bunch of really annoying different types: * a single type * a tuple of types * an arbitrary nested tree of tuples Return a flattened tuple of the given argument. )ÚsetÚ isinstanceÚtuplerÚflattenÚadd)Zsuitable_for_isinstancerOÚthingr r r rU†s    rUcCst|tƒr|gS|S)z] Wrap ``thing`` in a list if it's a single str. Otherwise, return it unchanged. )rSr)rWr r r Ú ensure_listœs rXcCst|ƒt|ƒkS)zQ Check if two things are equal, but evade booleans and ints being equal. ©Úunbool)ZoneZtwor r r Úequal¨sr[cCs|dur |S|dur|S|S)zH A hack to make True and 1 and False and 0 unique for ``uniq``. TFr )ÚelementÚtrueZfalser r r rZ¯s rZc CsÌz ttdd„|Dƒƒƒt|ƒkWStyÆzJtdd„|Dƒƒ}t |dd¡}t||ƒD]\}}||krZWYdSqZWnHttfyÀg}|D](}t|ƒ}||vr°YYdS|  |¡q’Yn0Yn0dS)zÙ Check if all of a container's elements are unique. Successively tries first to rely that the elements are hashable, then falls back on them being sortable, and finally falls back on brute force. css|]}t|ƒVqdSrrY©r2Úir r r r6År7zuniq..css|]}t|ƒVqdSrrYr^r r r r6Èr7r.NFT) rrRÚ TypeErrorÚsortedÚ itertoolsÚisliceÚzipÚNotImplementedErrorrZrM)Ú containerÚsortZslicedr_ÚjÚseenÚer r r Úuniq»s"    rk)r.)rbr(r%rDZjsonschema.compatrrrrÚobjectr$r-r;r@rIrLrQrUrXr[rZrkr r r r Ús"