
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
3
:X                 @   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 G dd deZG dd de	Z
dd Zdd
dZdd Zdd Zdd Zdd Zdd Zdd Ze	 e	 fddZdd ZdS )    N)	str_typesMutableMappingurlsplitc               @   sP   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd ZdS )URIDictz9
    Dictionary which uses normalized URIs as keys.

    c             C   s   t |j S )N)r   Zgeturl)selfuri r   /usr/lib/python3.6/_utils.py	normalize   s    zURIDict.normalizec             O   s   t  | _| jj|| d S )N)dictstoreupdate)r   argskwargsr   r   r	   __init__   s    zURIDict.__init__c             C   s   | j | j| S )N)r   r
   )r   r   r   r   r	   __getitem__   s    zURIDict.__getitem__c             C   s   || j | j|< d S )N)r   r
   )r   r   valuer   r   r	   __setitem__   s    zURIDict.__setitem__c             C   s   | j | j|= d S )N)r   r
   )r   r   r   r   r	   __delitem__   s    zURIDict.__delitem__c             C   s
   t | jS )N)iterr   )r   r   r   r	   __iter__   s    zURIDict.__iter__c             C   s
   t | jS )N)lenr   )r   r   r   r	   __len__"   s    zURIDict.__len__c             C   s
   t | jS )N)reprr   )r   r   r   r	   __repr__%   s    zURIDict.__repr__N)__name__
__module____qualname____doc__r
   r   r   r   r   r   r   r   r   r   r   r	   r   	   s   r   c               @   s   e Zd ZdZdd ZdS )UnsetzH
    An as-of-yet unset attribute or unprovided default parameter.

    c             C   s   dS )Nz<unset>r   )r   r   r   r	   r   /   s    zUnset.__repr__N)r   r   r   r   r   r   r   r   r	   r   )   s   r   c             C   s"   t jddj| }tj|jdS )zD
    Load a schema from ./schemas/``name``.json and return it.

    Z
jsonschemazschemas/{0}.jsonzutf-8)pkgutilget_dataformatjsonloadsdecode)namedatar   r   r	   load_schema3   s    r(      c                s   dj  fdd| j D S )zE
    A dumb version of :func:`textwrap.indent` from Python 3.3.

    
c             3   s   | ]}d d   | V  qdS )    Nr   ).0line)timesr   r	   	<genexpr>C   s    zindent.<locals>.<genexpr>)join
splitlines)stringr/   r   )r/   r	   indent=   s    r4   c             C   s    | sdS ddj dd | D  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             s   s   | ]}t |V  qd S )N)r   )r-   indexr   r   r	   r0   V   s    z"format_as_index.<locals>.<genexpr>)r1   )indicesr   r   r	   format_as_indexF   s    r8   c             c   sP   |j di }dj|j di }x,| D ]$}||kr$|rBtj||rBq$|V  q$W dS )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|ZpatternPropertiesN)getr1   research)instanceZschemar9   Zpatternspropertyr   r   r	   find_additional_propertiesY   s    
r@   c             C   s.   t | dkrd}nd}djdd | D |fS )zA
    Create an error message for extra items or properties.

    r)   ZwasZwerez, c             s   s   | ]}t |V  qd S )N)r   )r-   Zextrar   r   r	   r0   w   s    zextras_msg.<locals>.<genexpr>)r   r1   )ZextrasZverbr   r   r	   
extras_msgm   s    rA   c             C   s^   g }xF|D ]>}y|j t|d  W q
 tk
rF   |j t| Y q
X q
W d| dj|f S )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%r is not of type %sz, )appendr   	Exceptionr1   )r>   typesZreprstyper   r   r	   	types_msgz   s    
rF   c             C   sP   t  }t| ts| f} x0| D ](}t|tr:|jt| q|j| qW 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)Zsuitable_for_isinstancerD   thingr   r   r	   rJ      s    


rJ   c             C   s   t | tr| gS | S )z^
    Wrap ``thing`` in a list if it's a single str.

    Otherwise, return it unchanged.

    )rH   r   )rL   r   r   r	   ensure_list   s    
rM   c             C   s   | dkr|S | dkr|S | S )zI
    A hack to make True and 1 and False and 0 unique for ``uniq``.

    TFr   )elementtrueZfalser   r   r	   unbool   s
    rP   c             C   s   yt tdd | D t | kS  tk
r   yHtdd | D }tj|dd}x"t||D ]\}}||kr\dS q\W W nH ttfk
r   g }x*| D ]"}t|}||krdS |j	| qW Y nX Y nX dS )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             s   s   | ]}t |V  qd S )N)rP   )r-   ir   r   r	   r0      s    zuniq.<locals>.<genexpr>c             s   s   | ]}t |V  qd S )N)rP   )r-   rQ   r   r   r	   r0      s    r)   NFT)
r   rG   	TypeErrorsorted	itertoolsislicezipNotImplementedErrorrP   rB   )Z	containersortZslicedrQ   jseener   r   r	   uniq   s"    

r\   )r)   )rT   r#   r    r<   Zjsonschema.compatr   r   r   r   objectr   r(   r4   r8   r@   rA   rF   rJ   rM   rP   r\   r   r   r   r	   <module>   s     


	