Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
contego / home / tvault / .virtenv / lib / python2.7 / site-packages / jsonschema / validators.pyc
Size: Mime:
ó
³‹EYc@ s…ddlmZddlZddlZddlZyddlZWnek
r]dZnXddlm	Z	m
Z
ddlm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(tRefResolutionErrortSchemaErrortUnknownTypec s‡fd†}|S(s…
    Register the decorated validator for a ``version`` of the specification.

    Registered validators and their meta schemas will be considered when
    parsing ``$schema`` properties' URIs.

    Arguments:

        version (str):

            An identifier to use as the version's name

    Returns:

        callable: a class decorator to decorate the validator with the version

    c s1|tˆ<d|jkr-|t|jd<n|S(Nuid(t
validatorstMETA_SCHEMAtmeta_schemas(tcls(tversion(sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyt
_validates.s
((RR((RsJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyt	validatessc sµˆdkrOitd6td6td6tdƒd6tjd6td6td6‰ndt	f‡‡‡fd	†ƒY}|dk	r±t
|ƒ|ƒ}|jƒjd
dƒd|_
n|S(Nuarrayubooleanuintegerunullunumberuobjectustringt	Validatorc s†eZeˆƒZeˆƒZeˆƒZdddd„Zed„ƒZ	dd„Z
ddd„Zd„Zd„Z
dd„ZRS(	cS s_t|jƒ|_|jj|ƒ|dkr@tj|ƒ}n||_||_||_	dS(N(
tdictt
DEFAULT_TYPESt_typestupdatetNonetRefResolvertfrom_schematresolvertformat_checkertschema(tselfR"ttypesR R!((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyt__init__Cs		cS s6x/||jƒj|ƒD]}tj|ƒ‚qWdS(N(Rtiter_errorsRtcreate_from(RR"terror((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytcheck_schemaPscs sH|dkr|j}n|jdƒ}|r@|jj|ƒnzê|jdƒ}|dk	rpd|fg}nt|ƒ}xª|D]¢\}}|jj|ƒ}|dkr³qƒn|||||ƒpËd}	xT|	D]L}
|
jd|d|d|d|ƒ|dkr|
jj	|ƒn|
VqÕWqƒWWd|rC|jj
ƒnXdS(Nuidu$reft	validatortvalidator_valuetinstanceR"((RR"tgetR t
push_scopeRt
VALIDATORSt_settschema_patht
appendleftt	pop_scope(R#R,t_schematscopetrefRtktvR*terrorsR(((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyR&Us4
	cs sdx]|j||ƒD]I}|dk	r8|jj|ƒn|dk	rW|jj|ƒn|VqWdS(N(R&RtpathR2R1(R#R,R"R:R1R(((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytdescendxsc_ s'x |j||ŽD]}|‚qWdS(N(R&(R#targstkwargsR(((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytvalidate€scS sŽ||jkr't|||jƒ‚n|j|}t|tƒrtj|ƒ}td„|Dƒƒ}|rt|krtSnt||ƒS(Ncs s!|]}t|tjƒVqdS(N(t
issubclasstnumberstNumber(t.0tpytype((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pys	<genexpr>s(	RRR"t
isinstancetboolRtflattentanytFalse(R#R,ttypetpytypest	is_number((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytis_type„s
cS s%t|j||ƒdƒ}|dkS(N(tnextR&R(R#R,R4R(((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytis_valid“s(N(t__name__t
__module__RR/RRRR%tclassmethodR)R&R;R>RLRN((t
default_typestmeta_schemaR(sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyR>s#		t t(RtlistRER
RIR@RARR	tobjectRttitletreplaceRO(RSRRRRR((RRRSRsJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytcreate6s
"Y"c	C sAt|jƒ}|j|ƒtd|jd|d|d|jƒS(NRSRRRR(RR/RRZRR(R*RRtall_validators((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytextendžs
	RStdraft3Ru$refuadditionalItemsuadditionalPropertiesudependenciesudisallowudivisibleByuenumuextendsuformatuitemsumaxItemsu	maxLengthumaximumuminItemsu	minLengthuminimumu
multipleOfupatternupatternPropertiesu
propertiesutypeuuniqueItemsRtdraft4uallOfuanyOfu
maxPropertiesu
minPropertiesunotuoneOfurequiredRcB s­eZdZd
edddd„Zed„ƒZd„Zd„Z	e
d„ƒZe
d„ƒZe
jd„ƒZe
jd„ƒZd	„Zd
„Zd„Zd„ZRS(s&
    Resolve JSON References.

    Arguments:

        base_uri (str):

            The URI of the referring document

        referrer:

            The actual referring document

        store (dict):

            A mapping from URIs to documents to cache

        cache_remote (bool):

            Whether remote refs should be cached after first resolution

        handlers (dict):

            A mapping from URI schemes to functions that should be used
            to retrieve them

        urljoin_cache (functools.lru_cache):

            A cache that will be used for caching the results of joining
            the resolution scope to subscopes.

        remote_cache (functools.lru_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„ttƒDƒƒ|_
|j
j|ƒ||j
|<||_||_dS(Nics s$|]\}}||jfVqdS(N(R(RBtidR*((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pys	<genexpr>$s(RRRtresolve_from_urltreferrertcache_remoteRthandlerst
_scopes_stackRtURIDictRRtstoreRt_urljoin_cachet
_remote_cache(R#tbase_uriRaRfRbRct
urljoin_cachetremote_cache((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyR%s
		
	cO s||jddƒ|||ŽS(sÅ
        Construct a resolver from a JSON schema object.

        Arguments:

            schema:

                the referring schema

        Returns:

            :class:`RefResolver`

        uidu(R-(RR"R<R=((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyR-scC s#|jj|j|j|ƒƒdS(N(RdtappendRgtresolution_scope(R#R5((sJ/home/tvault/.virtenv/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#((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyR3Es

cC s|jdS(Niÿÿÿÿ(Rd(R#((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyRmOscC st|jƒ\}}|S(N(RRm(R#turit_((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyRiSscc s(|j|ƒz	dVWd|jƒXdS(N(R.R3(R#R5((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pytin_scopeXs
	cc s=|j|ƒ\}}|j|ƒz	|VWd|jƒXdS(sË
        Context manager which resolves a JSON ``ref`` and enters the
        resolution scope of this ref.

        Arguments:

            ref (str):

                The reference to resolve

        N(tresolveR.R3(R#R6turltresolved((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyt	resolving`s

	cC s(|j|j|ƒ}||j|ƒfS(N(RgRmRh(R#R6Rt((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyRsuscC s|t|ƒ\}}y|j|}WnFtk
rky|j|ƒ}Wqltk
rg}t|ƒ‚qlXnX|j||ƒS(N(RRftKeyErrortresolve_remotet	ExceptionRtresolve_fragment(R#Rttfragmenttdocumenttexc((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyR`ys
cC sÑ|jdƒ}|r*t|ƒjdƒng}xš|D]’}|jddƒjddƒ}t|tƒr‘yt|ƒ}Wq‘tk
rq‘Xny||}Wq7tt	fk
rÈt
d|ƒ‚q7Xq7W|S(sò
        Resolve a ``fragment`` within the referenced ``document``.

        Arguments:

            document:

                The referrant document

            fragment (str):

                a URI fragment to resolve within it

        u/u~1u~0u~sUnresolvable JSON pointer: %r(tlstripRtsplitRYRDRtintt
ValueErrort	TypeErrortLookupErrorR(R#R|R{tpartstpart((sJ/home/tvault/.virtenv/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|<n|S(sò
        Resolve a remote ``uri``.

        If called directly, does not check the store first, but after
        retrieving the document at the specified URI it will be saved in
        the store if :attr:`cache_remote` is True.

        .. note::

            If the requests_ library is present, ``jsonschema`` will use it to
            request the remote ``uri``, so that the correct encoding is
            detected and used.

            If it isn't, or if the scheme of the ``uri`` is not ``http`` or
            ``https``, UTF-8 is assumed.

        Arguments:

            uri (str):

                The URI to resolve

        Returns:

            The retrieved document

        .. _requests: http://pypi.python.org/pypi/requests/

        uhttpuhttpstjsonsutf-8(uhttpuhttpsN(RtschemeRctrequeststgetattrtResponseRtcallableR†R-tloadsRtreadtdecodeRbRf(R#RpR‡tresult((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyRxªs$	((N(RORPt__doc__tTrueRR%RQRR.R3tpropertyRmRit
contextlibtcontextmanagerRrRvRsR`RzRx(((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyRès"%		
			%cC s1|tkrt}ntj|jddƒ|ƒS(Nu$schemau(t_unsettDraft4ValidatorRR-(R"tdefault((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyt
validator_forás	cO sE|dkrt|ƒ}n|j|ƒ||||Žj|ƒdS(sv
    Validate an instance under the given schema.

        >>> 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`).


    Arguments:

        instance:

            The instance to validate

        schema:

            The schema to validate with

        cls (:class:`IValidator`):

            The 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=((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyR>çs3
((Ht
__future__RR“R†R@RˆtImportErrorRt
jsonschemaRRtjsonschema.compatRRRRRRR	R
RRtjsonschema.exceptionsR
RRRtUnsetR•RReRRRZR\tload_schemaR6tadditionalItemstadditionalPropertiestdependenciestdisallow_draft3t
multipleOftenumtextends_draft3tformattitemstmaxItemst	maxLengthtmaximumtminItemst	minLengthtminimumtpatterntpatternPropertiestproperties_draft3ttype_draft3tuniqueItemstDraft3ValidatortallOf_draft4tanyOf_draft4tmaxProperties_draft4tminProperties_draft4t
not_draft4toneOf_draft4tproperties_draft4trequired_draft4ttype_draft4R–RWRR˜R>(((sJ/home/tvault/.virtenv/lib/python2.7/site-packages/jsonschema/validators.pyt<module>s˜

F	h





















	

























	ù