a
    d%                     @   s   d dl mZmZmZ d dlmZ d dlZd dlZG dd deZG dd dZ	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d Zdd ZdS )    )MappingMutableMappingSequence)urlsplitNc                   @   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 )URIDictz8
    Dictionary which uses normalized URIs as keys.
    c                 C   s   t | S N)r   geturlselfuri r   Z/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/jsonschema/_utils.py	normalize   s    zURIDict.normalizec                 O   s   t  | _| jj|i | d S r   )dictstoreupdate)r
   argskwargsr   r   r   __init__   s    zURIDict.__init__c                 C   s   | j | | S r   r   r   r	   r   r   r   __getitem__   s    zURIDict.__getitem__c                 C   s   || j | |< d S r   r   )r
   r   valuer   r   r   __setitem__   s    zURIDict.__setitem__c                 C   s   | j | |= d S r   r   r	   r   r   r   __delitem__   s    zURIDict.__delitem__c                 C   s
   t | jS r   )iterr   r
   r   r   r   __iter__   s    zURIDict.__iter__c                 C   s
   t | jS r   )lenr   r   r   r   r   __len__   s    zURIDict.__len__c                 C   s
   t | jS r   )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 )UnsetzG
    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(   |s| S |  dd dd |D  dS )aA  
    Construct a single string containing indexing operations for the indices.

    For example for a container ``bar``, [1, 2, "foo"] -> bar[1][2]["foo"]

    Arguments:

        container (str):

            A word to use for the thing being indexed

        indices (sequence):

            The indices to format.
    [z][c                 s   s   | ]}t |V  qd S r   r   ).0indexr   r   r   	<genexpr>B       z"format_as_index.<locals>.<genexpr>])join)	containerindicesr   r   r   format_as_index/   s    r0   c                 c   sL   | di }d| di }| D ]$}||vr"|r@t||r@q"|V  q"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|patternPropertiesN)getr-   research)instanceschemar1   patternspropertyr   r   r   find_additional_propertiesE   s    
r;   c                 C   s0   t | dkrdnd}ddd t| D |fS )z@
    Create an error message for extra items or properties.
       waswerez, c                 s   s   | ]}t |V  qd S r   r'   )r(   extrar   r   r   r*   ^   r+   zextras_msg.<locals>.<genexpr>)r   r-   sorted)extrasZverbr   r   r   
extras_msgX   s    rB   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.
    )
isinstancestr)thingr   r   r   ensure_lista   s    
rF   c                    s.   t | t  krdS t fdd|  D S )zI
    Check if two mappings are equal using the semantics of `equal`.
    Fc                 3   s(   | ] \}}| v ot | | V  qd S r   equal)r(   keyr   twor   r   r*   s   s   z!_mapping_equal.<locals>.<genexpr>)r   allitemsZonerK   r   rJ   r   _mapping_equalm   s
    rO   c                 C   s,   t | t |krdS tdd t| |D S )zJ
    Check if two sequences are equal using the semantics of `equal`.
    Fc                 s   s   | ]\}}t ||V  qd S r   rG   )r(   ijr   r   r   r*      r+   z"_sequence_equal.<locals>.<genexpr>)r   rL   ziprN   r   r   r   _sequence_equaly   s    rS   c                 C   sh   t | tst |tr| |kS t | tr:t |tr:t| |S t | trXt |trXt| |S t| t|kS )z
    Check if two things are equal evading some Python type hierarchy semantics.

    Specifically in JSON Schema, evade `bool` inheriting from `int`,
    recursing into sequences to do the same.
    )rC   rD   r   rS   r   rO   unboolrN   r   r   r   rH      s    

rH   c                 C   s   | du r|S | du r|S | S )zH
    A hack to make True and 1 and False and 0 unique for ``uniq``.
    TFr   )elementtruefalser   r   r   rT      s
    rT   c              	   C   s   zJt dd | D }t|dd}t||D ]\}}t||r, W dS q,W nT ttfy   g }| D ]4}t|}|D ]}t||rt  Y dS qt|| qdY n0 dS )z
    Check if all of a container's elements are unique.

    Tries to rely on the container being recursively sortable, or otherwise
    falls back on (slow) brute force.
    c                 s   s   | ]}t |V  qd S r   )rT   )r(   rP   r   r   r   r*      r+   zuniq.<locals>.<genexpr>r<   NFT)	r@   	itertoolsislicerR   rH   NotImplementedError	TypeErrorrT   append)r.   sortZslicedrP   rQ   seener   r   r   uniq   s    

r`   c           
      C   s  |  |drg S g }d|v r.ttdt|S d|v rh| j|d }|t| j|j	|j
d||j	 d|v r|ttdt|d 7 }d|v r| j|d d|r|t| ||d 7 }d	|v r|t| ||d	 7 }nd
|v r|t| ||d
 7 }dD ]B}||v rt|D ],\}}| j|| d|r|| qqdD ]L}||v rB|| D ]2}t| ||d}	|	du rX|t| ||7 }qXqB|S )z
    Get all indexes of items that get evaluated under the current schema

    Covers all keywords related to unevaluatedItems: items, prefixItems, if,
    then, else, contains, unevaluatedItems, allOf, oneOf, anyOf
    booleanrM   r   $refr8   	_resolverZprefixItemsifr8   thenelse)containsZunevaluatedItemsZallOfoneOfZanyOfN)is_typelistranger   rd   lookupextend%find_evaluated_item_indexes_by_schemaevolvecontentsresolveris_valid	enumerater\   nextdescend)
	validatorr7   r8   Zevaluated_indexesresolvedkeywordkv	subschemaerrsr   r   r   rq      s\    




rq   c                 C   s  |  |drg S g }d|v rN| j|d }|t| j|j|jd||j dD ]Z}||v rR|| }|  |dr|r|| 7 }qR|  |drR|D ]}||v r|	| qqRd|v r|D ](}|d D ]}t
||r|	| qqd|v r |d  D ]$\}}	||vrq|t| ||	7 }qdD ]L}||v r$|| D ]2}	t| ||	d	}
|
d	u r:|t| ||	7 }q:q$d
|v r| j|d
 d|r|t| ||d
 7 }d|v r|t| ||d 7 }nd|v r|t| ||d 7 }|S )a  
    Get all keys of items that get evaluated under the current schema

    Covers all keywords related to unevaluatedProperties: properties,
    additionalProperties, unevaluatedProperties, patternProperties,
    dependentSchemas, allOf, oneOf, anyOf, if, then, else
    ra   rb   rc   )r1   ZadditionalPropertiesZunevaluatedPropertiesobjectr3   ZdependentSchemasrj   Nre   rf   rg   rh   )rl   rd   ro   rp   &find_evaluated_property_keys_by_schemarr   rs   rt   keysr\   r5   r6   rM   rw   rx   ru   )ry   r7   r8   Zevaluated_keysrz   r{   Zschema_valuer:   patternr~   r   r   r   r   r      st    









r   )collections.abcr   r   r   urllib.parser   rX   r5   r   r%   r0   r;   rB   rF   rO   rS   rH   r   rT   r`   rq   r   r   r   r   r   <module>   s    			?