
    M?                     R   S SK Jr  S SKrS SKrS SKr S SKrS SKJrJ	r	  S SK
JrJrJrJrJrJrJrJrJrJr  S SKJr  S SKJrJrJr  \R4                  " 5       r0 r\R:                  " 5       rS rS(S jr S)S	 jr!\ " \RD                  " S
5      0 S\	RF                  _S\	RH                  _S\	RJ                  _S\	RL                  _S\	RN                  _S\	RP                  _S\	RR                  _S\	RT                  _S\	RV                  _S\	RX                  _S\	RZ                  _S\	R\                  _S\	R^                  _S\	R`                  _S\	Rb                  _S\	Rd                  _S\	RP                  _\	Rf                  \	Rh                  \	Rj                  \	Rl                  \	Rn                  S.ES
S9r8\ " \RD                  " S5      0 S\	RF                  _S\	RH                  _S\	RJ                  _S\	Rr                  _S \	Rt                  _S\	RL                  _S\	RR                  _S\	RV                  _S\	RX                  _S\	RZ                  _S\	R\                  _S!\	Rv                  _S\	R^                  _S\	R`                  _S\	Rb                  _S"\	Rx                  _S\	Rd                  _\	RP                  \	Rz                  \	R|                  \	Rf                  \	Rh                  \	R~                  \	R                  \	R                  \	Rn                  S#.	ESS9rB " S$ S%\C5      rD\4S& jrES)S' jrFg! \ a    Sr GNf = f)*    )divisionN)_utils_validators)
Sequenceurljoinurlsplit	urldefragunquoteurlopen	str_types	int_types	iteritems	lru_cache)	ErrorTree)RefResolutionErrorSchemaErrorUnknownTypec                    ^  U 4S jnU$ )aa  
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                 f   > U [         T'   SU R                  ;   a  U [        U R                  S   '   U $ )Nid)
validatorsMETA_SCHEMAmeta_schemas)clsversions    (lib/third_party/jsonschema/validators.py
_validatesvalidates.<locals>._validates.   s1    !
7COO#36L/0
     )r   r   s   ` r   	validatesr!      s    &
 r   c                   ^ ^^ Tc5  [         [        [        [        S 5      [        R
                  [        [        S.m " UU U4S jS[        5      nUb9  [        U5      " U5      nUR                  5       R                  SS5      S-   Ul        U$ )N)arraybooleanintegernullnumberobjectstringc                      > \ rS rSr\"  Y5      r\"  Y5      r\"  Y 5      r SS jr\	S 5       r
SS jrSS jrS rS rSS	 jrS
rg)create.<locals>.Validator>   Nc                     [        U R                  5      U l        U R                  R                  U5        Uc  [        R                  U5      nX0l        X@l        Xl        g N)	dictDEFAULT_TYPES_typesupdateRefResolverfrom_schemaresolverformat_checkerschema)selfr7   typesr5   r6   s        r   __init__"create.<locals>.Validator.__init__C   sN     t112DKKKu%&226:$M"0 Kr   c                 |    U " U R                   5      R                  U5       H  n[        R                  " U5      e   g r.   )r   iter_errorsr   create_from)r   r7   errors      r   check_schema&create.<locals>.Validator.check_schemaP   s2    S__-99&A!--e44 Br   c           	   3   h  #    Uc  U R                   nUR                  S5      nU(       a  U R                  R                  U5         UR                  S5      nUb  SU4/nO[	        U5      nU Hw  u  pgU R
                  R                  U5      nUc  M%  U" XX5      =(       d    Sn	U	 H:  n
U
R                  UUUUS9  US:w  a  U
R                  R                  U5        U
v   M<     My     U(       a  U R                  R                  5         g g ! U(       a  U R                  R                  5         f f = f7f)Nr   $refr    )	validatorvalidator_valueinstancer7   )
r7   getr5   
push_scoper   
VALIDATORS_setschema_path
appendleft	pop_scope)r8   rF   _schemascoperefr   kvrD   errorsr?   s              r   r=   %create.<locals>.Validator.iter_errorsU   s    ++KK&E((/.kk'*?#*C.!1J!*7!3J&DA $ 3 3A 6I ( &tBHbF!'

&',-%-#*	 #  <!--88;# "( '$ MM++- 5MM++- s   AD2B"D (#D2$D//D2c              3      #    U R                  X5       HC  nUb  UR                  R                  U5        Ub  UR                  R                  U5        Uv   ME     g 7fr.   )r=   pathrL   rK   )r8   rF   r7   rV   rK   r?   s         r   descend!create.<locals>.Validator.descendx   sQ     ))(;#JJ))$/*%%00= <s   AAc                 6    U R                   " U0 UD6 H  nUe   g r.   )r=   )r8   argskwargsr?   s       r   validate"create.<locals>.Validator.validate   s!    ))4:6: ;r   c                    X R                   ;  a  [        X!U R                  5      eU R                   U   n[        U[        5      (       a:  [
        R                  " U5      n[        S U 5       5      nU(       a  [        U;  a  g[        X5      $ )Nc              3   V   #    U  H  n[        U[        R                  5      v   M!     g 7fr.   )
issubclassnumbersNumber).0pytypes     r   	<genexpr>4create.<locals>.Validator.is_type.<locals>.<genexpr>   s!       EL6Jvw~~66Ws   ')F)r1   r   r7   
isinstanceboolr   flattenany)r8   rF   typepytypes	is_numbers        r   is_type!create.<locals>.Validator.is_type   sy    ;;&!$$++>>kk$'G (D)) ..1  EL  	 W!4 h00r   c                 @    [        U R                  X5      S 5      nUS L $ r.   )nextr=   )r8   rF   rN   r?   s       r   is_valid"create.<locals>.Validator.is_valid   s#    ))(<dCED= r   )r1   r6   r5   r7   r    NNr.   )NN)__name__
__module____qualname____firstlineno__r/   rI   r   r0   r:   classmethodr@   r=   rW   r\   rn   rr   __static_attributes__)default_typesmeta_schemar   s   r   	Validatorr+   >   s[    *%
;']+ CG	! 
	5 
	5!	.F			1	!r   r}     )listrh   r   rk   ra   rb   r/   r   r(   r!   titlereplaceru   )r|   r   r   r{   r}   s   `` ` r   creater   6   s{    )$ZGNNt 
W! W!F W!r g&y1	$]]_44S"=K	r   c                     [        U R                  5      nUR                  U5        [        U R                  UUU R
                  S9$ )N)r|   r   r   r{   )r/   rI   r2   r   r   r0   )rD   r   r   all_validatorss       r   extendr      sE    )../N*%))!--	 r   draft3rC   additionalItemsadditionalPropertiesdependenciesdisallowdivisibleByenumextendsformatitemsmaxItems	maxLengthmaximumminItems	minLengthminimum
multipleOf)patternpatternProperties
propertiesrk   uniqueItems)r|   r   r   draft4allOfanyOfmaxPropertiesminProperties)	r   notoneOfr   r   r   requiredrk   r   c                       \ rS rSrSr     SS jr\S 5       rS rS r	\
S 5       r\
S	 5       r\R                  S
 5       r\R                  S 5       rS rS rS rS rSrg)r3      a  
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.

Nc                    Uc  [        S5      " [        5      nUc  [        S5      " U R                  5      nX l        X@l        [        U5      U l        U/U l        [        R                  " S [        [        5       5       5      U l        U R                  R                  U5        X R                  U'   X`l        Xpl        g )Ni   c              3   @   #    U  H  u  pXR                   4v   M     g 7fr.   )r   )rc   r   rD   s      r   re   'RefResolver.__init__.<locals>.<genexpr>#  s"      $
!8 &&'!8s   )r   r   resolve_from_urlreferrercache_remoter/   handlers_scopes_stackr   URIDictr   r   storer2   _urljoin_cache_remote_cache)r8   base_urir   r   r   r   urljoin_cacheremote_caches           r   r:   RefResolver.__init__  s      %dOG4M$T?4+@+@AL (X&Z^^ $
!*<!8$
 

 	

% '

8+)r   c                 <    U " UR                  SS5      U/UQ70 UD6$ )z
Construct a resolver from a JSON schema object.

Arguments:

    schema:

        the referring schema

Returns:

    :class:`RefResolver`

r   r   )rG   )r   r7   rZ   r[   s       r   r4   RefResolver.from_schema-  s&    " 6::eS)6CDCFCCr   c                 n    U R                   R                  U R                  U R                  U5      5        g r.   )r   appendr   resolution_scoper8   rO   s     r   rH   RefResolver.push_scope@  s,    !! 5 5u=	
r   c                 l     U R                   R                  5         g ! [         a    [        S5      ef = f)NznFailed to pop the scope from an empty stack. `pop_scope()` should only be called once for every `push_scope()`)r   pop
IndexErrorr   r8   s    r   rM   RefResolver.pop_scopeE  s:    	""$ 	$! 	s    3c                      U R                   S   $ )N)r   r   s    r   r   RefResolver.resolution_scopeO  s    !!"%%r   c                 4    [        U R                  5      u  pU$ r.   )r	   r   )r8   uri_s      r   r   RefResolver.base_uriS  s    4001
r   c              #      #    U R                  U5         S v   U R                  5         g ! U R                  5         f = f7fr.   )rH   rM   r   s     r   in_scopeRefResolver.in_scopeX  s-     	NNDNNs   ?* ?<?c              #      #    U R                  U5      u  p#U R                  U5         Uv   U R                  5         g! U R                  5         f = f7f)z
Context manager which resolves a JSON ``ref`` and enters the
resolution scope of this ref.

Arguments:

    ref (str):

        The reference to resolve

N)resolverH   rM   )r8   rP   urlresolveds       r   	resolvingRefResolver.resolving`  sA      S)	NNNDNNs   %A= AAAc                 ^    U R                  U R                  U5      nX R                  U5      4$ r.   )r   r   r   )r8   rP   r   s      r   r   RefResolver.resolveu  s.    !!$"7"7=&&s+++r   c                     [        U5      u  p U R                  U   nU R                  X25      $ ! [         a2     U R                  U5      n N/! [         a  n[        U5      eS nAff = ff = fr.   )r	   r   KeyErrorresolve_remote	Exceptionr   resolve_fragment)r8   r   fragmentdocumentexcs        r   r   RefResolver.resolve_from_urly  ss    !#	.zz#H $$X88  	....s3 .(--.	.s&   / 
A+A
A'A""A''A+c                 t   UR                  S5      nU(       a  [        U5      R                  S5      O/ nU HK  nUR                  SS5      R                  SS5      n[	        U[
        5      (       a   [        U5      n X   nMM     U$ ! [         a     Nf = f! [        [        4 a    [        SU-  5      ef = f)z
Resolve a ``fragment`` within the referenced ``document``.

Arguments:

    document:

        The referrant document

    fragment (str):

        a URI fragment to resolve within it

/z~1z~0~zUnresolvable JSON pointer: %r)lstripr
   splitr   rg   r   int
ValueError	TypeErrorLookupErrorr   )r8   r   r   partsparts        r   r   RefResolver.resolve_fragment  s      ??4(19!''-rD<<t,44UDAD(H--t9D#>    "  {+ (3h> s   2B>B
BBB7c                 f   [        U5      R                  nX R                  ;   a  U R                  U   " U5      nOUS;   a  [        (       a  [	        [        R
                  SS5      bn  [        [        R
                  R                  5      (       a%  [        R                  " U5      R                  5       nO][        R                  " U5      R                  nO<[        R                  " [        U5      R                  5       R                  S5      5      nU R                  (       a  X0R                  U'   U$ )aj  
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/

)httphttpsjsonNzutf-8)r   schemer   requestsgetattrResponsecallabler   rG   loadsr   readdecoder   r   )r8   r   r   results       r   r   RefResolver.resolve_remote  s    > #%%]]"]]6*3/F))HH%%vt4@ ))..//!c*//1!c*// ZZ 1 1 3 : :7 CDF$JJsOr   )r   r   r   r   r   r   r   )r    Tr    NN)ru   rv   rw   rx   __doc__r:   ry   r4   rH   rM   propertyr   r   
contextlibcontextmanagerr   r   r   r   r   r   rz   r    r   r   r3   r3      s    $T *< D D$

 & &      (,
9#J4r   r3   c                 l    U[         L a  [        n[        R                  U R                  SS5      U5      $ )Nz$schemar   )_unsetDraft4Validatorr   rG   )r7   defaults     r   validator_forr     s-    &!FJJz37AAr   c                 x    Uc  [        U5      nUR                  U5        U" U/UQ70 UD6R                  U 5        g)a  
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)r   r@   r\   )rF   r7   r   rZ   r[   s        r   r\   r\     s?    f {F#V   ))(3r   rt   r.   )G
__future__r   r   r   ra   r   ImportError
jsonschemar   r   jsonschema.compatr   r   r   r	   r
   r   r   r   r   r   jsonschema.exceptionsr   r   r   r   Unsetr   r   r   r   r!   r   r   load_schemarP   r   r   r   disallow_draft3r   r   extends_draft3r   r   r   r   r   r   r   r   r   r   properties_draft3type_draft3r   Draft3ValidatorallOf_draft4anyOf_draft4maxProperties_draft4minProperties_draft4
not_draft4oneOf_draft4properties_draft4required_draft4type_draft4r   r(   r3   r   r\   r    r   r   <module>r     s       +   , N N 

~~6eP ""8,K77 	 !A!A 	11	
 	[00 	.. 	!! 	K.. 	;%% 	+## 	[)) 	k++ 	K'' 	[)) 	k++  	K''!" 	{--#$  '');;"44((#//-0 5: ""8,K77 	 !A!A 	+**	
 	+** 	11 	!! 	;%% 	+## 	[)) 	k++ 	+:: 	K'' 	[)) 	k++  	+::!" 	K''#$ #--&&**'');;"44 00((#//58 =Dv& vr #) B64}  Hs   L L&%L&