ó ‚ß+Uc@ s…ddlmZddlZddlZddlZyddlZWnek r]dZnXddlm Z m Z ddl m Z m Z mZmZmZmZmZmZmZmZddlmZddlmZmZmZe jƒZiZe jƒZd„Z d0ddd„Z!dd „Z"e!d e j#d ƒd ie j$d 6e j%d6e j&d6e j'd6e j(d6e j)d6e j*d6e j+d6e j,d6e j-d6e j.d6e j/d6e j0d6e j1d6e j2d6e j3d6e j)d6e j4d6e j5d6e j6d 6e j7d!6e j8d"6d#d ƒZ9e!d e j#d$ƒd ie j$d 6e j%d6e j&d6e j:d%6e j;d&6e j'd6e j*d6e j,d6e j-d6e j.d6e j/d6e j<d'6e j0d6e j1d6e j2d6e j=d(6e j3d6e j)d6e j>d)6e j?d*6e j4d6e j5d6e j@d 6e jAd+6e jBd!6e j8d"6d#d$ƒZCd,eDfd-„ƒYZEed.„ZFdd/„ZGdS(1iÿÿÿÿ(tdivisionN(t_utilst _validators( tSequenceturljointurlsplitt urldefragtunquoteturlopent str_typest int_typest iteritemst lru_cache(t ErrorTree(tRefResolutionErrort SchemaErrort UnknownTypec s‡fd†}|S(sY Register the decorated validator for a ``version`` of the specification. Registered validators and their meta schemas will be considered when parsing ``$schema`` properties' URIs. :argument str version: an identifier to use as the version's name :returns: a class decorator to decorate the validator with the version c s1|tˆ†s( RRR"t isinstancetboolRtflattentanytFalse(R#R,ttypetpytypest is_number((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pytis_type}s cS s%t|j||ƒdƒ}|dkS(N(tnextR&R(R#R,R4R(((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pytis_validŒs(N(t__name__t __module__RR/RRRR%t classmethodR)R&R;R>RLRN((t default_typest meta_schemaR(s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyR7s     #  t t(RtlistRER RIR@RARR tobjectRttitletreplaceRO(RSRRRRR((RRRSRs9/usr/lib/python2.7/site-packages/jsonschema/validators.pytcreate/s  "Y "c C sAt|jƒ}|j|ƒtd|jd|d|d|jƒS(NRSRRRR(RR/RRZRR(R*RRtall_validators((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pytextend—s  RStdraft3Ru$refuadditionalItemsuadditionalPropertiesu dependenciesudisallowu divisibleByuenumuextendsuformatuitemsumaxItemsu maxLengthumaximumuminItemsu minLengthuminimumu multipleOfupatternupatternPropertiesu propertiesutypeu uniqueItemsRtdraft4uallOfuanyOfu maxPropertiesu minPropertiesunotuoneOfurequiredRcB s­eZdZd edddd„Zed„ƒZd„Zd„Z e d„ƒZ e d„ƒZ e jd„ƒZe jd„ƒZd „Zd „Zd „Zd „ZRS(sÍ Resolve JSON References. :argument str base_uri: URI of the referring document :argument referrer: the actual referring document :argument dict store: a mapping from URIs to documents to cache :argument bool cache_remote: whether remote refs should be cached after first resolution :argument dict handlers: a mapping from URI schemes to functions that should be used to retrieve them :arguments functools.lru_cache urljoin_cache: a cache that will be used for caching the results of joining the resolution scope to subscopes. :arguments functools.lru_cache remote_cache: a cache that will be used for caching the results of resolved remote URLs. cC sÇ|dkr!tdƒtƒ}n|dkrEtdƒ|jƒ}n||_||_t|ƒ|_|g|_t j d„t t ƒDƒƒ|_ |j j|ƒ||j |<||_||_dS(Nics s$|]\}}||jfVqdS(N(R(RBtidR*((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pys s(RR Rtresolve_from_urltreferrert cache_remoteRthandlerst _scopes_stackRtURIDictR RtstoreRt_urljoin_cachet _remote_cache(R#tbase_uriRaRfRbRct urljoin_cachet remote_cache((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyR%ós       cO s||jddƒ|||ŽS(s— Construct a resolver from a JSON schema object. :argument schema: the referring schema :rtype: :class:`RefResolver` uidu(R-(RR"R<R=((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyRs cC s#|jj|j|j|ƒƒdS(N(RdtappendRgtresolution_scope(R#R5((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyR.s cC s5y|jjƒWntk r0tdƒ‚nXdS(NsnFailed to pop the scope from an empty stack. `pop_scope()` should only be called once for every `push_scope()`(Rdtpopt IndexErrorR(R#((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyR3"s  cC s |jdS(Niÿÿÿÿ(Rd(R#((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyRm,scC st|jƒ\}}|S(N(RRm(R#turit_((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyRi0scc s(|j|ƒz dVWd|jƒXdS(N(R.R3(R#R5((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pytin_scope5s  cc s=|j|ƒ\}}|j|ƒz |VWd|jƒXdS(s¦ Context manager which resolves a JSON ``ref`` and enters the resolution scope of this ref. :argument str ref: reference to resolve N(tresolveR.R3(R#R6turltresolved((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyt resolving=s   cC s(|j|j|ƒ}||j|ƒfS(N(RgRmRh(R#R6Rt((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyRsNscC s|t|ƒ\}}y|j|}WnFtk rky|j|ƒ}Wqltk rg}t|ƒ‚qlXnX|j||ƒS(N(RRftKeyErrortresolve_remotet ExceptionRtresolve_fragment(R#Rttfragmenttdocumenttexc((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyR`Rs cC sÑ|jdƒ}|r*t|ƒjdƒng}xš|D]’}|jddƒjddƒ}t|tƒr‘yt|ƒ}Wq‘tk rq‘Xny||}Wq7tt fk rÈt d|ƒ‚q7Xq7W|S(sÅ Resolve a ``fragment`` within the referenced ``document``. :argument document: the referrant document :argument str fragment: a URI fragment to resolve within it u/u~1u~0u~sUnresolvable JSON pointer: %r( tlstripRtsplitRYRDRtintt ValueErrort TypeErrort LookupErrorR(R#R|R{tpartstpart((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyRz^s !  cC sát|ƒj}||jkr4|j||ƒ}n|dkr tr ttjddƒdk r ttjjƒr‹tj |ƒjƒ}qÄtj |ƒj}n$tj t |ƒj ƒj dƒƒ}|jrÝ||j|>> validate([2, 3, 4], {"maxItems" : 2}) Traceback (most recent call last): ... ValidationError: [2, 3, 4] is too long :func:`validate` will first verify that the provided schema is itself valid, since not doing so can lead to less obvious error messages and fail in less obvious or consistent ways. If you know you have a valid schema already or don't care, you might prefer using the :meth:`~IValidator.validate` method directly on a specific validator (e.g. :meth:`Draft4Validator.validate`). :argument instance: the instance to validate :argument schema: the schema to validate with :argument cls: an :class:`IValidator` class that will be used to validate the instance. If the ``cls`` argument is not provided, two things will happen in accordance with the specification. First, if the schema has a :validator:`$schema` property containing a known meta-schema [#]_ then the proper validator will be used. The specification recommends that all schemas contain :validator:`$schema` properties for this reason. If no :validator:`$schema` property is found, the default validator class is :class:`Draft4Validator`. Any other provided positional and keyword arguments will be passed on when instantiating the ``cls``. :raises: :exc:`ValidationError` if the instance is invalid :exc:`SchemaError` if the schema itself is invalid .. rubric:: Footnotes .. [#] known by a validator registered with :func:`validates` N(RR˜R)R>(R,R"RR<R=((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyR>²s)  ((Ht __future__RR“R†R@Rˆt ImportErrorRt jsonschemaRRtjsonschema.compatRRRRRRR R R R tjsonschema.exceptionsR RRRtUnsetR•RReRRRZR\t load_schemaR6tadditionalItemstadditionalPropertiest dependenciestdisallow_draft3t multipleOftenumtextends_draft3tformattitemstmaxItemst maxLengthtmaximumtminItemst minLengthtminimumtpatterntpatternPropertiestproperties_draft3t type_draft3t uniqueItemstDraft3Validatort allOf_draft4t anyOf_draft4tmaxProperties_draft4tminProperties_draft4t not_draft4t oneOf_draft4tproperties_draft4trequired_draft4t type_draft4R–RWRR˜R>(((s9/usr/lib/python2.7/site-packages/jsonschema/validators.pyts˜     F   h                                                   Ë