
                             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  G d de      Z G d de	      Z
d ZddZd	 Zd
 Zd Zd Zd Zd Z e	        e	       fdZd Zy)    N)	str_typesMutableMappingurlsplitc                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)URIDictz9
    Dictionary which uses normalized URIs as keys.

    c                 4    t        |      j                         S N)r   geturlselfuris     $lib/third_party/jsonschema/_utils.py	normalizezURIDict.normalize   s    }##%%    c                 Z    t               | _         | j                  j                  |i | y r	   )dictstoreupdate)r   argskwargss      r   __init__zURIDict.__init__   s$    V


4*6*r   c                 >    | j                   | j                  |         S r	   r   r   r   s     r   __getitem__zURIDict.__getitem__   s    zz$..-..r   c                 @    || j                   | j                  |      <   y r	   r   )r   r   values      r   __setitem__zURIDict.__setitem__   s    */

4>>#&'r   c                 <    | j                   | j                  |      = y r	   r   r   s     r   __delitem__zURIDict.__delitem__   s    JJt~~c*+r   c                 ,    t        | j                        S r	   )iterr   r   s    r   __iter__zURIDict.__iter__       DJJr   c                 ,    t        | j                        S r	   )lenr   r"   s    r   __len__zURIDict.__len__"   s    4::r   c                 ,    t        | j                        S r	   )reprr   r"   s    r   __repr__zURIDict.__repr__%   r$   r   N)__name__
__module____qualname____doc__r   r   r   r   r   r#   r'   r*    r   r   r   r   	   s/    
&+/0,  r   r   c                       e Zd ZdZd Zy)UnsetzH
    An as-of-yet unset attribute or unprovided default parameter.

    c                      y)Nz<unset>r/   r"   s    r   r*   zUnset.__repr__/   s    r   N)r+   r,   r-   r.   r*   r/   r   r   r1   r1   )   s    
r   r1   c                     t        j                  ddj                  |             }t        j                  |j                  d            S )zD
    Load a schema from ./schemas/``name``.json and return it.

    
jsonschemazschemas/{0}.jsonzutf-8)pkgutilget_dataformatjsonloadsdecode)namedatas     r   load_schemar=   3   s:     L*<*C*CD*IJD::dkk'*++r   c                 T    dj                  fd| j                         D              S )zE
    A dumb version of :func:`textwrap.indent` from Python 3.3.

    
c              3   4   K   | ]  }d dz  z  |z     yw)    Nr/   ).0linetimess     r   	<genexpr>zindent.<locals>.<genexpr>C   s"     N:M$SAI&-:Ms   )join
splitlines)stringrE   s    `r   indentrJ   =   s#     99N&:K:K:MNNNr   c                 >    | syddj                  d | D              z  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][c              3   2   K   | ]  }t        |        y wr	   r)   )rC   indexs     r   rF   z"format_as_index.<locals>.<genexpr>V   s     ?wed5kw   )rG   )indicess    r   format_as_indexrR   F   s$     DII?w????r   c              #      K   |j                  di       }dj                  |j                  di             }| D ]$  }||vs|rt        j                  ||      r!| & yw)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|patternPropertiesN)getrG   research)instanceschemarT   patternspropertys        r   find_additional_propertiesr^   Y   s\      L"-Jxx

#6;<H:%BIIh9N	 s   =A   A c                 \    t        |       dk(  rd}nd}dj                  d | D              |fS )zA
    Create an error message for extra items or properties.

       waswere, c              3   2   K   | ]  }t        |        y wr	   rN   )rC   extras     r   rF   zextras_msg.<locals>.<genexpr>w   s     5fUT%[frP   )r&   rG   )extrasverbs     r   
extras_msgrh   m   s4     6{a995f55t;;r   c                     g }|D ]   }	 |j                  t        |d                " | ddj                  |      S # t        $ r |j                  t        |             Y ^w xY w)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 is not of type rc   )appendr)   	ExceptionrG   )rZ   typesreprstypes       r   	types_msgro   z   sd     E	%LLd6l+, 
 &.tyy/?@@  	%LLd$	%s   >#A$#A$c                     t               }t        | t              s| f} | D ]>  }t        |t              r|j                  t	        |             .|j                  |       @ t        |      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)suitable_for_isinstancerl   things      r   rt   rt      s[     EE-u5#:"<(eU#LL(IIe	 )
 <r   c                 ,    t        | t              r| gS | S )z^
    Wrap ``thing`` in a list if it's a single str.

    Otherwise, return it unchanged.

    )rr   r   )rw   s    r   ensure_listry      s     %#wLr   c                     | du r|S | du r|S | S )zI
    A hack to make True and 1 and False and 0 unique for ``uniq``.

    TFr/   )elementtruefalses      r   unboolr~      s"     $	E	Nr   c                    	 t        t        d | D                    t        |       k(  S # t        $ r 	 t        d | D              }t	        j
                  |dd      }t        ||      D ]  \  }}||k(  s Y y Y y# t        t        f$ r1 g }| D ]&  }t        |      }||v r Y Y y|j                  |       ( Y Y yw xY ww xY w)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.

    c              3   2   K   | ]  }t        |        y wr	   r~   rC   is     r   rF   zuniq.<locals>.<genexpr>   s     4)Qvay)rP   c              3   2   K   | ]  }t        |        y wr	   r   r   s     r   rF   zuniq.<locals>.<genexpr>   s     7Y&)YrP   r`   NFT)
r&   rq   	TypeErrorsorted	itertoolsislicezipNotImplementedErrorr~   rj   )	containersortslicedr   jseenes          r   uniqr      s    34)445YGG 	7Y77D%%dAt4FD&)16  *  $Y/ 	D1I9 A	 
 	s?   &) 	B>A A:4A:7A::&B: B>#B:6B>9B::B>)r`   )r   r8   r5   rX   jsonschema.compatr   r   r   r   objectr1   r=   rJ   rR   r^   rh   ro   rt   ry   r~   r   r/   r   r   <module>r      sp       	 A A n  @F ,O@&(
<A(.
   
r   