
    Oh%.                        d dl Z d dlZd dlZd dlZd dlZd dlZd dlmZ d dlm	Z	m
Z
 d dlmZmZmZmZmZmZmZmZ ddlmZ ej*                  r d dlZej.                  dk  rd dlmZ nd dlmZ  ej4                  e      Zd	d
dddZdZh dZ ej@                  d      Z! ej@                  dejD                        Z#dddddZ$dZ% G d de      Z&eded   fd       Z' G d d      Z( G d d      Z)d e*dee*   fd!Z+y)"    N)contextmanager)indentwrap)AnyDict	GeneratorIteratorListOptionalSequenceUnion   )JsonSchemaValueException)      )Selfzkeys must be named byzat least one item that matches z"only items matching the definition)z(must be named by propertyName definitionzone of contains definitionz same as const definition:zonly specified items)zmust not be emptyzis always invalidzmust not be there>   notallOfanyOfitemsoneOfcontainspropertyNamesz\W+|([A-Z][^A-Z\W]*)z^[\w_]+$tablekeykeys)objectproperty
propertiesproperty namesz}
For more details about `format` see
https://validate-pyproject.readthedocs.io/en/latest/api/validate_pyproject.formats.html
c                   6    e Zd ZdZdZdZdZededdfd       Z	y)ValidationErrora  Report violations of a given JSON schema.

    This class extends :exc:`~fastjsonschema.JsonSchemaValueException`
    by adding the following properties:

    - ``summary``: an improved version of the ``JsonSchemaValueException`` error message
      with only the necessary information)

    - ``details``: more contextual information about the error like the failing schema
      itself and the value that violates the schema.

    Depending on the level of the verbosity of the ``logging`` configuration
    the exception message will be only ``summary`` (default) or a combination of
    ``summary`` and ``details`` (when the logging level is set to :obj:`logging.DEBUG`).
    r   exreturnr   c                    t        |      } | t        |      |j                  |j                  |j                  |j
                        }t        j                  dd      j                         }|dk7  r#|j                  |j                  c|_	        |_
        |j                  |_        |j                  |_        |j                  |_        |S )N JSONSCHEMA_DEBUG_CODE_GENERATIONfalse)_ErrorFormattingstrvaluename
definitionruleosgetenvlower	__cause____traceback__message_original_messagesummarydetails)clsr$   	formatterobj
debug_codes        /mnt/c/Users/Administrator/Desktop/help_/test_env/lib/python3.12/site-packages/setuptools/config/_validate_pyproject/error_reporting.py_from_jsonschemaz ValidationError._from_jsonschemaK   s    $R(	#i."((INNBMM277SYYA7KQQS
 /1||R=M=M,CM3, "

''''
    N)
__name__
__module____qualname____doc__r6   r7   r5   classmethodr   r=    r>   r<   r#   r#   6   s:      GG	": 	v 	 	r>   r#   r%   )NNNc               #   d   K   	 d  y # t         $ r} t        j                  |       d d } ~ ww xY wwN)r   r#   r=   )r$   s    r<   detailed_errorsrG   X   s0     =# =..r2<=s   0	 0	-(-0c                       e Zd ZdefdZdefdZedefd       Zedefd       Z	e
dedefd       Zdefd	Zdefd
Zy)r)   r$   c                     || _         d| j                  |j                         d| _        | j                   j                  j	                  |j                  | j                        | _        d| _        d| _        y )N`r   )r$   _simplify_namer,   r4   replacer5   _summary_details)selfr$   s     r<   __init__z_ErrorFormatting.__init__a   s\    ++BGG45Q7	&*ggoo&=&=bggtyy&Qr>   r%   c                     t         j                         t        j                  k  r'| j                  r| j
                   d| j                   S | j
                  S )N

)_loggergetEffectiveLevelloggingDEBUGr7   r6   rO   s    r<   __str__z_ErrorFormatting.__str__h   s@    $$&'--7DLLll^4~66||r>   c                 \    | j                   s| j                         | _         | j                   S rF   )rM   _expand_summaryrW   s    r<   r6   z_ErrorFormatting.summaryn   #    }} 002DM}}r>   c                 \    | j                   s| j                         | _         | j                   S rF   )rN   _expand_detailsrW   s    r<   r7   z_ErrorFormatting.detailsu   r[   r>   r,   c                 H    t        d      }| j                  d      r| |d  S | S )Nzdata.)len
startswith)r,   xs     r<   rK   z_ErrorFormatting._simplify_name|   s'    L??73tABx==r>   c                 d   | j                   t        j                         D ]  \  }}j                  ||       t	        fdt
        D              rS | j                  j                  }| j                  j                  t        v r(|r&t        t              } dt         ||      d       S S )Nc              3   &   K   | ]  }|v  
 y wrF   rD   ).0	substringmsgs     r<   	<genexpr>z3_ErrorFormatting._expand_summary.<locals>.<genexpr>   s     ?IyC?   z:

    )r5   _MESSAGE_REPLACEMENTSr   rL   any_SKIP_DETAILSr$   rule_definitionr.   _NEED_DETAILS_SummaryWriter_TOML_JARGONr   )rO   badreplschemar6   rf   s        @r<   rZ   z _ErrorFormatting._expand_summary   s    $$.446 	)IC++c4(C	) ???J((77<<=(V$\2GU%wv ?@AA
r>   c           	      n   g }| j                   j                  xs i }|j                  dg       }|j                  dd       xs dj                  |      }|r3dj                  t	        |dddd            }|j                  d	|        t        j                  |d
      }t        j                  | j                   j                  d
      }dt        |d       d| j                   j                  dt        |d       g}dj                  ||z         }	d|	j                         v r	dt         nd}
|	|
z   S )Nz$$descriptiondescription 
P   ri   F)widthinitial_indentsubsequent_indentbreak_long_wordszDESCRIPTION:
   )r   zGIVEN VALUE:
zOFFENDING RULE: zDEFINITION:
rR   formatr   )r$   r-   popjoinr   appendjsondumpsr+   r   r.   r1   _FORMATS_HELP)rO   optionalr-   
desc_linesdescru   rs   r+   defaultsrf   epilogs              r<   r]   z _ErrorFormatting._expand_details   s&   WW''-2
^^OR8
~~mT2Jchhz6J))#)&,%*K OOn[M:;Jq1

477==3VE6234tww||./F66234

 kk(X-.)1SYY[)@2m_%bV|r>   N)r?   r@   rA   r   rP   r*   rX   r   r6   r7   staticmethodrK   rZ   r]   rD   r>   r<   r)   r)   `   s    3         >S >S > >   r>   r)   c            
          e Zd Z ed      Zddeeeef      fdZde	ee
e   f   de	ee
e   f   fdZ	 ddd	d
e	ee
e   f   dedee   defdZdee   defdZd
eeef   dee   deeef   fdZdedee   dee   fdZ	 ddededee   defdZdee   defdZdee   defdZdedee   defdZd
edee   dee   fdZdededefdZy)ro   )ru   defaulttitleexamplesNjargonc                     |xs i | _         dddd| j                  d       dddd| j                  d	       | j                  d
       dddd| _        g d| _        y )Nzat least one of the followingzexactly one of the followingzall of the followingz(*NOT* the following)r   z (in order)zcontains at least one ofznon-predefined acceptable r!   r    z named via patternzpredefined valuezone of)r   r   r   r   prefixItemsr   r   r   patternPropertiesconstenum)r   r   	maxLength	minLengthpatternr~   minimummaximumexclusiveMinimumexclusiveMaximum
multipleOf)r   _jargon_terms_guess_inline_defs)rO   r   s     r<   rP   z_SummaryWriter.__init__   sx    &,l 53+*"ll734K@2,T\\:J-K,LM$(LL$>#??Q!R'
"#
r>   termr%   c                     t        |t              r*|D cg c]  }| j                  j                  ||        c}S | j                  j                  ||      S c c}w rF   )
isinstancelistr   get)rO   r   ts      r<   r   z_SummaryWriter._jargon   sF    dD!378aDKKOOAq)88{{tT** 9s   #ArD   _pathrs   prefixr   c          
         t        |t              r| j                  |||      S | j                  ||      }| j	                  ||      }|r| | S | j                  |d      }| j                  |d      }t        |      dz  }t        j                         5 }	t        |j                               D ]  \  }
\  }}g ||}|
dk(  r|n|}|	j                  | | j                  |       d       t        |t              rI| j                  ||      }| j	                  ||      }|	j                  |rd| nd | |||              t        |t              rT|dk7  s| j                  |      r>| j                  |||      }|j                  d	      rdnd}|	j                  | |        |	j                  d| j!                  ||       d       " |	j#                         cd d d        S # 1 sw Y   y xY w)
Nz  - rv   r   :rw   r   type[)r   r   _handle_list_filter_unecessary_handle_simple_dict_child_prefixr_   ioStringIO	enumerater   write_labeldict_is_propertyr`   _valuegetvalue)rO   rs   r   r   filteredsimplechild_prefixitem_prefixr   bufferir   r+   
child_pathline_prefixchildrenseps                    r<   __call__z_SummaryWriter.__call__   s    fd#$$VVU;;**659))(E:XfX&&))&$7((6Vs"[[] 	%f#,X^^-=#> I<C*u]c]
()QfF}T[[-D,EQGHeT*#66ujIH!55h
KFLL! F8!$ul*"M!NO
  t,6MT%6%6z%B#00ZPH!)!4!4S!9#tCLLC5
!34LL1T[[
%C$DB!GH)I* ??$-	% 	% 	%s   EG,,G5pathc                 ~    | j                  |      s|sy|d   t        fddD              xs | j                  v S )NFc              3   @   K   | ]  }j                  |        y wrF   )r`   )rd   kr   s     r<   rg   z0_SummaryWriter._is_unecessary.<locals>.<genexpr>  s     33>>!$3s   z$_)r   rk   _IGNORE)rO   r   r   s     @r<   _is_unecessaryz_SummaryWriter._is_unecessary  s>    T"$2h3d33Jsdll7JJr>   c                     |j                         D ci c]  \  }}| j                  g ||      s|| c}}S c c}}w rF   )r   r   )rO   rs   r   r   r+   s        r<   r   z!_SummaryWriter._filter_unecessary  sH    
 %lln
U&&||s|4 J
 	
 
s   ":r+   c                     t        fd| j                  D              }t        d j                         D               }|s|r%ddj                  | j	                  |             dS y )Nc              3   &   K   | ]  }|v  
 y wrF   rD   )rd   pr+   s     r<   rg   z5_SummaryWriter._handle_simple_dict.<locals>.<genexpr>  s     AAQ%ZArh   c              3   H   K   | ]  }t        |t        t        f        y wrF   )r   r   r   )rd   vs     r<   rg   z5_SummaryWriter._handle_simple_dict.<locals>.<genexpr>  s     MAd|4Ms    "{, z}
)rk   r   valuesr   _inline_attrs)rO   r+   r   inliner   s    `   r<   r   z"_SummaryWriter._handle_simple_dict  s`    A)@)@AAMellnMMMV		$"4"4UD"ABC4HHr>   schemasc                       j                        ryt        |      }t        d |D              rt        |      dk  r| dS  j	                  |d      dj                   fdt        |      D              S )Nr   c              3   J   K   | ]  }t        |t        t        f         y wrF   )r   r   r   )rd   es     r<   rg   z._SummaryWriter._handle_list.<locals>.<genexpr>  s     @1:a$..@s   !#<   rw   r   c           	   3   J   K   | ]  \  }} |g d | d        yw)r   ]r   NrD   )rd   r   r   r   r   rO   s      r<   rg   z._SummaryWriter._handle_list.<locals>.<genexpr>"  s9      
>BaDK'8'81#Qx'899
s    #)r   reprallr_   r   r   r   )rO   r   r   r   repr_r   s   `  ` @r<   r   z_SummaryWriter._handle_list  sz     t$W@@@SZRT_WB<((6ww 
FOPWFX
 
 	
r>   c                 F    d}|ddd   D ]  }|dvr n|dz  } |dz  dk(  S )zGCheck if the given path can correspond to an arbitrarily named propertyr   Nr   >   r    r   r      rD   )rO   r   counterr   s       r<   r   z_SummaryWriter._is_property&  sF    B< 	C==qLG	 {ar>   c                     |^ }}| j                  |      sHt        |      }| j                  j                  |      xs  dj	                  | j                  |            S |d   dk(  rd|dS t        |      S )Nrv   r   r   z(regex ))r   _separate_termsr   r   r   r   r   )rO   r   parentsr   norm_keys        r<   r   z_SummaryWriter._label2  ss    #  &&s+H;;??3'K388DLL4J+KK2;--SG1%%Cyr>   c                     |d   dk(  rI| j                  |      s8| j                  |      }t        |t              rddj	                  |       dS |S t        |      S )Nr   r   r   r   r   )r   r   r   r   r   r   )rO   r+   r   type_s       r<   r   z_SummaryWriter._value<  sZ    8vd&7&7&=LL'E.8.EQtyy'(*P5PE{r>   c              #      K   |j                         D ]3  \  }}g ||}| j                  |       d| j                  ||        5 y w)Nz: )r   r   r   )rO   rs   r   r   r+   r   s         r<   r   z_SummaryWriter._inline_attrsB  sU      ,,. 	QJC%4J[[,-RE:0N/OPP	Qs   AA
parent_prefixr   c                 $    t        |      dz  |z   S )Nrv   )r_   )rO   r   r   s      r<   r   z_SummaryWriter._child_prefixG  s    =!C',66r>   rF   )r   )r   rD   )r?   r@   rA   	frozensetr   r   r   r*   rP   r   r
   r   r   r   r   boolr   r   r   r   r   r   r   r   r   r	   r   r   rD   r>   r<   ro   ro      s   GHG 
xS#X7  
D+E#tCy.1 +eCcN6K + (%
  "(%dDJ&'(% (%
 }(% 
(%TK8C= KT K
38n
,4SM
	c3h
 Xc] xPS}  FH

%(
5=c]
	

 # 
 4 
 8C= S C x}  QD Q Q(3- Q
73 7c 7c 7r>   ro   wordc                 t    t         j                  |       D cg c]  }|s|j                          c}S c c}w )zE
    >>> _separate_terms("FooBar-foo")
    ['foo', 'bar', 'foo']
    )_CAMEL_CASE_SPLITTERsplitr1   )r   ws     r<   r   r   K  s+    
  499$?E!1AGGIEEEs   55),r   r   rU   r/   retyping
contextlibr   textwrapr   r   r   r   r   r	   r
   r   r   r   fastjsonschema_exceptionsr   TYPE_CHECKINGsysversion_infotyping_extensionsr   	getLoggerr?   rS   rj   rl   rn   compiler   I_IDENTIFIERrp   r   r#   rG   r)   ro   r*   r   rD   r>   r<   <module>r     s(   	   	 	  % ! R R R ?	
'!*
'

H
% 1H"B"$@	  Y!rzz"9: bjjbdd+ 	. D =#34 = =J JZ[7 [7|F# F$s) Fr>   