
    d(                        d dl mZmZmZ d dlmZ d dlZd dlZd dlZd dl	Z	e	j
        dk    rd dlmZ nd dlZ G d de          Z G d d	          Zd
 Zd Zd Zd Zd Zd Zd Zd Z e             e            fdZd Zd Zd ZdS )    )MappingMutableMappingSequence)urlsplitN)   	   )	resourcesc                   B    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
S )URIDictz8
    Dictionary which uses normalized URIs as keys.
    c                 D    t          |                                          S N)r   geturlselfuris     U/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/jsonschema/_utils.py	normalizezURIDict.normalize   s    }}##%%%    c                 P    t                      | _         | j        j        |i | d S r   )dictstoreupdate)r   argskwargss      r   __init__zURIDict.__init__   s-    VV

4*6*****r   c                 B    | j         |                     |                   S r   r   r   r   s     r   __getitem__zURIDict.__getitem__   s    z$..--..r   c                 @    || j         |                     |          <   d S r   r   )r   r   values      r   __setitem__zURIDict.__setitem__   s     */
4>>#&&'''r   c                 <    | j         |                     |          = d S r   r   r   s     r   __delitem__zURIDict.__delitem__!   s    Jt~~c**+++r   c                 *    t          | j                  S r   )iterr   r   s    r   __iter__zURIDict.__iter__$       DJ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 0 0, , ,                r   r   c                       e Zd ZdZd ZdS )UnsetzG
    An as-of-yet unset attribute or unprovided default parameter.
    c                     dS )Nz<unset>r3   r&   s    r   r.   zUnset.__repr__3   s    yr   N)r/   r0   r1   r2   r.   r3   r   r   r5   r5   .   s-             r   r5   c                     t          j        t                                        d|  d          }|                    d          }t          j        |          S )zC
    Load a schema from ./schemas/``name``.json and return it.
    zschemas/z.jsonzutf-8)encoding)r	   files__package__joinpath	read_textjsonloads)namepathdatas      r   load_schemarB   7   sP    
 ?;''001GD1G1G1GHHD>>7>++D:dr   c                 T    |s| S |  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              3   4   K   | ]}t          |          V  d S r   r-   ).0indexs     r   	<genexpr>z"format_as_index.<locals>.<genexpr>T   s(      #E#EEDKK#E#E#E#E#E#Er   ])join)	containerindicess     r   format_as_indexrN   A   sD    "  HH$))#E#EW#E#E#EEEHHHHr   c              #      K   |                     di           }d                    |                     di                     }| D ]"}||vr|rt          j        ||          r|V  #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)getrK   research)instanceschemarP   patternspropertys        r   find_additional_propertiesrZ   W   s       L"--Jxx

#6;;<<H  :%% BIh99 NNN	 r   c                     t          |           dk    rd}nd}d                    d t          |           D                       |fS )z@
    Create an error message for extra items or properties.
       waswerez, c              3   4   K   | ]}t          |          V  d S r   rF   )rG   extras     r   rI   zextras_msg.<locals>.<genexpr>s   s(      ==UT%[[======r   )r*   rK   sorted)extrasverbs     r   
extras_msgrd   j   sM    
 6{{a99==fVnn=====tCCr   c                 6    t          | t                    r| gS | S )z]
    Wrap ``thing`` in a list if it's a single str.

    Otherwise, return it unchanged.
    )
isinstancestr)things    r   ensure_listri   v   s"     % wLr   c                     t          |           t                    k    rdS t          fd|                                 D                       S )zI
    Check if two mappings are equal using the semantics of `equal`.
    Fc              3   R   K   | ]!\  }}|v ot          ||                   V  "d S r   equal)rG   keyr    twos      r   rI   z!_mapping_equal.<locals>.<genexpr>   sR        C 	s
-uUCH--     r   )r*   allitemsonero   s    `r   _mapping_equalrt      sa     3xx3s88u    ))++     r   c                     t          |           t          |          k    rdS t          d t          | |          D                       S )zJ
    Check if two sequences are equal using the semantics of `equal`.
    Fc              3   <   K   | ]\  }}t          ||          V  d S r   rl   )rG   ijs      r   rI   z"_sequence_equal.<locals>.<genexpr>   s.      55tq!uQ{{555555r   )r*   rp   ziprr   s     r   _sequence_equalrz      sE     3xx3s88u55s3}}555555r   c                    t          | t                    st          |t                    r| |k    S t          | t                    r%t          |t                    rt          | |          S t          | t                    r%t          |t                    rt          | |          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.
    )rf   rg   r   rz   r   rt   unboolrr   s     r   rm   rm      s     #s z#s33 cz#x   )ZX%>%> )sC(((#w (JsG$<$< (c3'''#;;&++%%r   c                     | du r|S | du r|S | S )zH
    A hack to make True and 1 and False and 0 unique for ``uniq``.
    TFr3   )elementtruefalses      r   r|   r|      s'    
 $	E		Nr   c                 r   	 t          d | D                       }t          j        |dd          }t          ||          D ]\  }}t	          ||          r dS n\# t
          t          f$ rH g }| D ]@}t          |          }|D ]}t	          ||          r  Y dS |                    |           AY nw xY w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              3   4   K   | ]}t          |          V  d S r   )r|   )rG   rw   s     r   rI   zuniq.<locals>.<genexpr>   s(      33AfQii333333r   r\   NFT)	ra   	itertoolsislicery   rm   NotImplementedError	TypeErrorr|   append)rL   sortslicedrw   rx   seenes          r   uniqr      s	   3333333!$400f%% 	 	DAqQ{{ uu	  + 	 	 	 	 	Aq		A ! !A;; ! 5555! KKNNNN	 		 4s   AA A <B4B43B4c           
         |                      |d          rg S g }d|v r*t          t          dt          |                              S d|v r| j                            |d                   \  }}| j                            |           	 |t          | ||          z  }| j                                         n# | j                                         w xY wd|v r3|t          t          dt          |d                                       z  }d|v r| 	                    |d                   
                    |          r9|t          | ||d                   z  }d|v r|t          | ||d                   z  }nd	|v r|t          | ||d	                   z  }d
D ]_}||v rYt          |          D ]I\  }}| 	                    ||                   
                    |          r|                    |           J`dD ]J}||v rD||         D ];}	t          |                     ||	                    }
|
s|t          | ||	          z  }<K|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
    booleanrq   r   $refprefixItemsifrW   thenelse)containsunevaluatedItemsallOfoneOfanyOf)is_typelistranger*   resolverresolve
push_scope%find_evaluated_item_indexes_by_schema	pop_scopeevolveis_valid	enumerater   descend)	validatorrV   rW   evaluated_indexesscoperesolvedkeywordkv	subschemaerrss              r   r   r      s    ++ 	&E!S]]++,,,#,44VF^DDx%%e,,,	+!F8X" "  ((****I((****T%3vm/D+E+E"F"FGGGv~~6$<0099(CC 	!F8VD\" "  !%Jx& & ! !%Jx& & ! 4 0 0f!(++ 0 01##6'?#;;DDQGG 0%,,Q///.  f#G_  	I--h	BBCC %)N!8Y* * % s   B9 9Cc                    |                      |d          rg S g }d|v r| j                            |d                   \  }}| j                            |           	 |t	          | ||          z  }| j                                         n# | j                                         w xY wdD ]}||v r |                      ||         d          r`|                                D ]K\  }}|                     ||                                       ||i          r|	                    |           L|                      ||         d          rh||                                         D ]M\  }}	||v rD|                     |	                              ||                   r|	                    |           N
d|v r|                                D ]\  }}|d                                         D ]`\  }
}t          j        |
|          rF|                     |d                                       ||i          r|	                    |           ad|v r9|d                                         D ]\  }}	||vr
|t	          | ||	          z  }dD ]J}||v rD||         D ];}	t          |                     ||	                    }|s|t	          | ||	          z  }<Kd	|v r|                     |d	                                       |          r9|t	          | ||d	                   z  }d
|v r|t	          | ||d
                   z  }nd|v r|t	          | ||d                   z  }|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
    r   r   )rP   additionalPropertiesunevaluatedPropertiesr   objectrR   dependentSchemasr   r   r   r   )r   r   r   r   &find_evaluated_property_keys_by_schemar   rq   r   r   r   rT   rU   r   r   )r   rV   rW   evaluated_keysr   r   r   rY   r    r   pattern_r   s                r   r   r     s?    ++ 	N#,44VF^DDx%%e,,,	+D8X  N ((****I((**** 8 8 f  )<< 8'/~~'7'7 8 8OHe ''vg'??HH!5)  8 '--h777  (;; 8+1'?+@+@+B+B 8 8'Hi8++	0@0@( 1A 1 1hx122 , '--h777f$$'~~// 	4 	4OHe$%89??AA 4 4
9Wh// 4I4D4D!"56 5E 5 5(He,--4 #))(333	4 V###)*<#=#C#C#E#E 	 	Hix''D8Y  NN /  f#G_  	I--h	BBCC "&L!8Y' ' N v~~6$<0099(CC 	D8VD\  N "Hx# #  "Hx# #  s   B B&)collections.abcr   r   r   urllib.parser   r   r=   rT   sysversion_info	importlibr	   importlib_resourcesr   r5   rB   rN   rZ   rd   ri   rt   rz   rm   r   r|   r   r   r   r3   r   r   <module>r      s   = = = = = = = = = = ! ! ! ! ! !      				 



 v#######++++         n      >         I I I,  &	D 	D 	D	 	 		 	 	6 6 6& & &    	 	 	 	  8: : :zQ Q Q Q Qr   