ó
ž›V]c           @   sî   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z m Z m Z d e f d „  ƒ  YZ d e	 f d „  ƒ  YZ
 d „  Z d d	 „ Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z e	 ƒ  e	 ƒ  d „ Z d „  Z d S(   iÿÿÿÿN(   t   MutableMappingt	   str_typest   urlsplitt   URIDictc           B   sV   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 RS(	   s9   
    Dictionary which uses normalized URIs as keys.

    c         C   s   t  | ƒ j ƒ  S(   N(   R   t   geturl(   t   selft   uri(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt	   normalize   s    c         O   s#   t  ƒ  |  _ |  j j | | Ž  d  S(   N(   t   dictt   storet   update(   R   t   argst   kwargs(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   __init__   s    c         C   s   |  j  |  j | ƒ S(   N(   R	   R   (   R   R   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   __getitem__   s    c         C   s   | |  j  |  j | ƒ <d  S(   N(   R	   R   (   R   R   t   value(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   __setitem__   s    c         C   s   |  j  |  j | ƒ =d  S(   N(   R	   R   (   R   R   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   __delitem__   s    c         C   s   t  |  j ƒ S(   N(   t   iterR	   (   R   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   __iter__   s    c         C   s   t  |  j ƒ S(   N(   t   lenR	   (   R   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   __len__"   s    c         C   s   t  |  j ƒ S(   N(   t   reprR	   (   R   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   __repr__%   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R   (    (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyR   	   s   							t   Unsetc           B   s   e  Z d  Z d „  Z RS(   sH   
    An as-of-yet unset attribute or unprovided default parameter.

    c         C   s   d S(   Ns   <unset>(    (   R   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyR   /   s    (   R   R   R   R   (    (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyR   )   s   c         C   s1   t  j d d j |  ƒ ƒ } t j | j d ƒ ƒ S(   sD   
    Load a schema from ./schemas/``name``.json and return it.

    t
   jsonschemas   schemas/{0}.jsons   utf-8(   t   pkgutilt   get_datat   formatt   jsont   loadst   decode(   t   namet   data(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   load_schema3   s    i   c            s#   d j  ‡  f d †  |  j ƒ  Dƒ ƒ S(   s?   
    A dumb version of `textwrap.indent` from Python 3.3.

    s   
c         3   s!   |  ] } d  d ˆ  | Vq d S(   t    i   N(    (   t   .0t   line(   t   times(    s0   lib/python2.7/site-packages/jsonschema/_utils.pys	   <genexpr>C   s    (   t   joint
   splitlines(   t   stringR)   (    (   R)   s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   indent=   s    c         C   s%   |  s
 d Sd d j  d „  |  Dƒ ƒ S(   sÖ   
    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.

    t    s   [%s]s   ][c         s   s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R'   t   index(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pys	   <genexpr>V   s    (   R*   (   t   indices(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   format_as_indexF   s    c         c   st   | j  d i  ƒ } d j | j  d i  ƒ ƒ } x@ |  D]8 } | | k r4 | rd t j | | ƒ rd q4 n  | Vq4 q4 Wd S(   sî   
    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.

    t
   propertiest   |t   patternPropertiesN(   t   getR*   t   ret   search(   t   instancet   schemaR2   t   patternst   property(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   find_additional_propertiesY   s    c         C   s>   t  |  ƒ d k r d } n d } d j d „  |  Dƒ ƒ | f S(   sA   
    Create an error message for extra items or properties.

    i   t   wast   weres   , c         s   s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R'   t   extra(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pys	   <genexpr>w   s    (   R   R*   (   t   extrast   verb(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt
   extras_msgm   s    	c         C   sp   g  } xP | D]H } y | j  t | d ƒ ƒ Wq t k
 rT | j  t | ƒ ƒ q Xq Wd |  d j | ƒ f S(   s,  
    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#   s   %r is not of type %ss   , (   t   appendR   t	   ExceptionR*   (   R8   t   typest   reprst   type(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt	   types_msgz   s    c         C   sq   t  ƒ  } t |  t ƒ s$ |  f }  n  x@ |  D]8 } t | t ƒ rV | j t | ƒ ƒ q+ | j | ƒ q+ Wt | ƒ S(   sã   
    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.

    (   t   sett
   isinstancet   tupleR
   t   flattent   add(   t   suitable_for_isinstanceRE   t   thing(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyRL   Ž   s    	c         C   s   t  |  t ƒ r |  g S|  S(   s^   
    Wrap ``thing`` in a list if it's a single str.

    Otherwise, return it unchanged.

    (   RJ   R   (   RO   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   ensure_list¥   s    c         C   s   t  |  ƒ t  | ƒ k S(   sQ   
    Check if two things are equal, but evade booleans and ints being equal.
    (   t   unbool(   t   onet   two(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   equal²   s    c         C   s$   |  t  k r | S|  t k r  | S|  S(   sH   
    A hack to make True and 1 and False and 0 unique for ``uniq``.
    (   t   Truet   False(   t   elementt   truet   false(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyRQ   ¹   s
    c         C   sû   y* t  t d „  |  Dƒ ƒ ƒ t  |  ƒ k SWnÊ t k
 rö y_ t d „  |  Dƒ ƒ } t j | d d ƒ } x- t | | ƒ D] \ } } | | k rx t Sqx WWq÷ t	 t f k
 rò g  } x; |  D]/ } t
 | ƒ } | | k rÞ t S| j | ƒ q¼ Wq÷ Xn Xt S(   sÙ   
    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.
    c         s   s   |  ] } t  | ƒ Vq d  S(   N(   RQ   (   R'   t   i(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pys	   <genexpr>Ï   s    c         s   s   |  ] } t  | ƒ Vq d  S(   N(   RQ   (   R'   RZ   (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pys	   <genexpr>Ò   s    i   N(   R   RI   t	   TypeErrort   sortedt	   itertoolst   islicet   Nonet   zipRV   t   NotImplementedErrorRQ   RC   RU   (   t	   containert   sortt   slicedRZ   t   jt   seent   e(    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   uniqÅ   s"    	*(   R]   R    R   R6   t   jsonschema.compatR    R   R   R   t   objectR   R%   R-   R1   R<   RB   RH   RL   RP   RT   RQ   Rh   (    (    (    s0   lib/python2.7/site-packages/jsonschema/_utils.pyt   <module>   s"    
	
								