o
    g)                     @   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   M/var/www/html/chatdoc2/venv/lib/python3.10/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   
   t | jS r   )iterr   r
   r   r   r   __iter__      
zURIDict.__iter__c                 C   r   r   )lenr   r   r   r   r   __len__   r   zURIDict.__len__c                 C   r   r   )reprr   r   r   r   r   __repr__"   r   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 )aB  
    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       | ]}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    r3   c                 c   sN    | 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)getr0   research)instanceschemar4   patternspropertyr   r   r   find_additional_propertiesE   s   	r>   c                 C   s,   t | dkrdnd}ddd | D |fS )z@
    Create an error message for extra items or properties.
       waswerez, c                 s   r)   r   r*   )r+   extrar   r   r   r-   \   r.   zextras_msg.<locals>.<genexpr>)r   r0   )extrasverbr   r   r   
extras_msgW   s   rE   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_list_   s   
rI   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-   p   s
    
z!_mapping_equal.<locals>.<genexpr>)r   allitemsonerN   r   rM   r   _mapping_equalj   s
   rS   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   rJ   )r+   ijr   r   r   r-   |   s    z"_sequence_equal.<locals>.<genexpr>)r   rO   ziprQ   r   r   r   _sequence_equalv   s   rW   c                 C   st   | |u rdS t | tst |tr| |kS t | tr#t |tr#t| |S t | tr2t |tr2t| |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.
    T)rF   rG   r   rW   r   rS   unboolrQ   r   r   r   rK      s   

rK   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   rX      s
   rX   c              	   C   s   z&t dd | D }t|dd}t||D ]\}}t||r# W dS qW dS  ttfyQ   g }| D ]}t|}|D ]}t||rG  Y dS q;|| q3Y dS w )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   r)   r   )rX   )r+   rT   r   r   r   r-      r.   zuniq.<locals>.<genexpr>r?   NFT)	sorted	itertoolsislicerV   rK   NotImplementedError	TypeErrorrX   append)r1   sortslicedrT   rU   seener   r   r   uniq   s*   


rf   c                 C   s  |  |drg S g }d|v rttt|S |d}|dur6| j|}|t| j	|j
|jd||j
 |d}|durV| j|}|t| j	|j
|jd||j
 d|v rf|tt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 ]}||v rt|D ]\}}	| j	|| d	|	r|| qqdD ]"}||v r|| D ]}
t| ||
d}|du r|t| ||
7 }qq|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
    booleanrP   $refNr;   	_resolver$dynamicRefprefixItemsifr;   thenelse)containsunevaluatedItemsallOfoneOfanyOf)is_typelistranger   r7   rj   lookupextend%find_evaluated_item_indexes_by_schemaevolvecontentsresolveris_valid	enumeratera   nextdescend)	validatorr:   r;   evaluated_indexesrefresolved
dynamicRefkeywordkv	subschemaerrsr   r   r   r|      s~   





r|   c                 C   s$  |  |drg S g }|d}|dur*| j|}|t| j|j|jd||j |d}|durJ| j|}|t| j|j|jd||j dD ]-}||v ry|| }|  |dre|re||	 7 }qL|  |dry|D ]}	|	|v rx|
|	 qmqLd|v r|D ]}	|d D ]}
t|
|	r|
|	 qqd	|v r|d	  D ]\}	}|	|vrq|t| ||7 }qd
D ]"}||v r|| D ]}t| ||d}|du r|t| ||7 }qqd|v r| j|d d|r|t| ||d 7 }d|v r|t| ||d 7 }|S 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
    rg   rh   Nri   rk   )r4   additionalPropertiesunevaluatedPropertiesobjectr6   dependentSchemasrs   rm   rn   ro   rp   )rw   r7   rj   rz   r{   &find_evaluated_property_keys_by_schemar}   r~   r   keysra   r8   r9   rP   r   r   r   )r   r:   r;   evaluated_keysr   r   r   r   schema_valuer=   patternr   r   r   r   r   r     s   








r   )collections.abcr   r   r   urllib.parser   r]   r8   r   r'   r3   r>   rE   rI   rS   rW   rK   r   rX   rf   r|   r   r   r   r   r   <module>   s"    		M