3 Fã\©ã@s´ddlZddlZddlZddlZddlmZmZmZGdd„deƒZGdd„de ƒZ dd„Z dd d „Z d d „Z dd„Zdd„Zdd„Zdd„Zdd„Ze ƒe ƒfdd„Zdd„ZdS)éN)Ú str_typesÚMutableMappingÚurlsplitc@sPeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dS)ÚURIDictz9 Dictionary which uses normalized URIs as keys. cCs t|ƒjƒS)N)rÚgeturl)ÚselfÚuri©r úm/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-install-emcbgzcf/jsonschema/jsonschema/_utils.pyÚ normalizeszURIDict.normalizecOstƒ|_|jj||ŽdS)N)ÚdictÚstoreÚupdate)rÚargsÚkwargsr r r Ú__init__szURIDict.__init__cCs|j|j|ƒS)N)r r )rrr r r Ú __getitem__szURIDict.__getitem__cCs||j|j|ƒ<dS)N)r r )rrÚvaluer r r Ú __setitem__szURIDict.__setitem__cCs|j|j|ƒ=dS)N)r r )rrr r r Ú __delitem__szURIDict.__delitem__cCs t|jƒS)N)Úiterr )rr r r Ú__iter__szURIDict.__iter__cCs t|jƒS)N)Úlenr )rr r r Ú__len__"szURIDict.__len__cCs t|jƒS)N)Úreprr )rr r r Ú__repr__%szURIDict.__repr__N) Ú__name__Ú __module__Ú __qualname__Ú__doc__r rrrrrrrr r r r r src@seZdZdZdd„ZdS)ÚUnsetzH An as-of-yet unset attribute or unprovided default parameter. cCsdS)Nzr )rr r r r/szUnset.__repr__N)rrrrrr r r r r )sr cCs"tjddj|ƒƒ}tj|jdƒƒS)zD 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_schema3sr)écsdj‡fdd„|jƒDƒƒS)zE A dumb version of :func:`textwrap.indent` from Python 3.3. Ú c3s|]}ddˆ|VqdS)ú éNr )Ú.0Úline)Útimesr r ú Cszindent..)ÚjoinÚ splitlines)Ústringr0r )r0r Úindent=sr5cCs |sdSddjdd„|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|ƒVqdS)N)r)r.Úindexr r r r1Vsz"format_as_index..)r2)Úindicesr r r Úformat_as_indexFsr9ccsP|jdiƒ}dj|jdiƒƒ}x,|D]$}||kr$|rBtj||ƒrBq$|Vq$WdS)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)Úgetr2ÚreÚsearch)ÚinstanceZschemar:ÚpatternsÚpropertyr r r Úfind_additional_propertiesYs  rBcCs.t|ƒdkrd}nd}djdd„|Dƒƒ|fS)zA Create an error message for extra items or properties. r*ÚwasÚwerez, css|]}t|ƒVqdS)N)r)r.Úextrar r r r1wszextras_msg..)rr2)ÚextrasZverbr r r Ú extras_msgms rGc Cs^g}xF|D]>}y|jt|dƒƒWq tk rF|jt|ƒƒYq Xq Wd|dj|ƒ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 %sz, )ÚappendrÚ Exceptionr2)r?ÚtypesZreprsÚtyper r r Ú types_msgzs  rLcCsPtƒ}t|tƒs|f}x0|D](}t|tƒr:|jt|ƒƒq|j|ƒqWt|ƒ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_isinstancerJÚthingr r r rPŽs    rPcCst|tƒr|gS|S)z^ Wrap ``thing`` in a list if it's a single str. Otherwise, return it unchanged. )rNr)rRr r r Ú ensure_list¥s rScCs|dkr |S|dkr|S|S)zI A hack to make True and 1 and False and 0 unique for ``uniq``. TFr )ÚelementÚtrueÚfalser r r Úunbool²s rWcCsÊyttdd„|Dƒƒƒt|ƒkStk rÄyHtdd„|Dƒƒ}tj|ddƒ}x"t||ƒD]\}}||kr\dSq\WWnHttfk r¾g}x*|D]"}t|ƒ}||kr¬dS|j |ƒq”WYnXYnXdS)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|ƒVqdS)N)rW)r.Úir r r r1Êszuniq..css|]}t|ƒVqdS)N)rW)r.rXr r r r1Ísr*NFT) rrMÚ TypeErrorÚsortedÚ itertoolsÚisliceÚzipÚNotImplementedErrorrWrH)Ú containerÚsortZslicedrXÚjÚseenÚer r r Úuniq¿s"   rd)r*)r[r$r!r=Zjsonschema.compatrrrrÚobjectr r)r5r9rBrGrLrPrSrWrdr r r r Ús