
    Mhg!                     n   d Z ddlmZ ddlmZ ddlm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 n# e$ r	 ddlmZ Y nw xY wddlmZmZ ddlmZ dd	lmZmZ  e
j        d
ed            G d de          Ze G d d                      Ze G d d                      Ze G d d                      Zd Z ej        d          Z e !                    ddddd           e !                    ddd !           e !                    d"d#d$d%gd$d&'           e !                    d(d)ed*+           e !                    d,d-!           e !                    d.d/ ej"        d0          1           e !                    d2d3!           d4 Z#d5 Z$ej%        d6d         fd7Z&ej'        ej(        ej)        fd8Z*dS )9z"
The ``jsonschema`` command line.
    )metadata)JSONDecodeError)dedentNresolve_name)definefield)SchemaError)_RefResolvervalidator_forzThe jsonschema CLI is deprecated and will be removed in a future version. Please use check-jsonschema instead, which can be installed from https://pypi.org/project/check-jsonschema/   )
stacklevelc                       e Zd ZdS )_CannotLoadFileN)__name__
__module____qualname__     N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/jsonschema/cli.pyr   r   #   s        Dr   r   c                   ~    e Zd Z e            Z e            Z e            Zed             Zd Z	d Z
d Zd Zd ZdS )
_Outputterc                     |d         dk    rt          |d                   }n|d         dk    rt                      } | |||          S )Noutputplainerror_formatpretty)	formatterstdoutstderr)_PlainFormatter_PrettyFormatter)cls	argumentsr   r    r   s        r   from_argumentsz_Outputter.from_arguments.   sX    X'))'	.(ABBIIx H,,(**IsYvfEEEEr   c                    	 t          |          }nI# t          $ r<}|                     |t          j                               t                      |d }~ww xY w|5  	 t          j        |          cd d d            S # t          $ r<}| 	                    |t          j                               t                      |d }~ww xY w# 1 swxY w Y   d S )Npathexc_info)
openFileNotFoundErrorfilenotfound_errorsysr)   r   jsonloadr   parsing_error)selfr(   fileerrors       r   r/   z_Outputter.load6   s*   	/::DD  	/ 	/ 	/###GGG!##.	/  	3 	33y	3 	3 	3 	3 	3 	3 	3 	3 # 3 3 3""s|~~"FFF%''U23	3 	3 	3 	3 	3 	3 	3 	3 	3 	3sD    
A7AACA??
C	7C  CCCCc                 Z    | j                              | j        j        di |           d S Nr   )_stderrwrite
_formatterr,   r1   kwargss     r   r,   z_Outputter.filenotfound_errorD   4    =4?=GGGGHHHHHr   c                 Z    | j                              | j        j        di |           d S r5   )r6   r7   r8   r0   r9   s     r   r0   z_Outputter.parsing_errorG   s4    84?8BB6BBCCCCCr   c                 Z    | j                              | j        j        di |           d S r5   )r6   r7   r8   validation_errorr9   s     r   r>   z_Outputter.validation_errorJ   s4    ;4?;EEfEEFFFFFr   c                 Z    | j                              | j        j        di |           d S r5   )_stdoutr7   r8   validation_successr9   s     r   rA   z_Outputter.validation_successM   r;   r   N)r   r   r   r	   r8   r@   r6   classmethodr%   r/   r,   r0   r>   rA   r   r   r   r   r   '   s         JeggGeggGF F [F3 3 3I I ID D DG G GI I I I Ir   r   c                   @    e Zd Z ed          ZdZd Zd Zd Zd Z	dS )r"   z`        ===[{type}]===({path})===

        {body}
        -----------------------------
        z===[SUCCESS]===({path})===
c                 B    | j                             |d|d          S )Nr+   z does not exist.r(   typebody)
_ERROR_MSGformatr1   r(   r)   s      r   r,   z#_PrettyFormatter.filenotfound_error^   s3    %%$,,, & 
 
 	
r   c                     |\  }}}d                     t          j        |||                    }| j                            ||j        |          S )N rE   )join	tracebackformat_exceptionrH   rI   r   )r1   r(   r)   exc_type	exc_valueexc_traceback	exc_liness          r   r0   z_PrettyFormatter.parsing_errore   s`    -5*)]GG&xMJJ
 
	 %%" & 
 
 	
r   c                 P    | j                             ||j        j        |          S )NrE   )rH   rI   	__class__r   r1   instance_pathr3   s      r   r>   z!_PrettyFormatter.validation_errorp   s/    %%) & 
 
 	
r   c                 8    | j                             |          S )N)r(   )_SUCCESS_MSGrI   r1   rW   s     r   rA   z#_PrettyFormatter.validation_successw   s     '']';;;r   N)
r   r   r   r   rH   rY   r,   r0   r>   rA   r   r   r   r"   r"   Q   so         	 J 2L
 
 
	
 	
 	

 
 
< < < < <r   r"   c                   :    e Zd Z e            Zd Zd Zd Zd ZdS )r!   c                     |dS )Nz does not exist.
r   rJ   s      r   r,   z"_PlainFormatter.filenotfound_error   s    ,,,,r   c                 d    d                     |dk    rdnt          |          |d                   S )NzFailed to parse {}: {}
<stdin>   )rI   reprrJ   s      r   r0   z_PlainFormatter.parsing_error   s8    )00**IIT

QK
 
 	
r   c                 :    | j                             ||          S )N)	file_namer3   )_error_formatrI   rV   s      r   r>   z _PlainFormatter.validation_error   s    !((=(NNNr   c                     dS )NrL   r   rZ   s     r   rA   z"_PlainFormatter.validation_success   s    rr   N)	r   r   r   r	   rc   r,   r0   r>   rA   r   r   r   r!   r!   {   s`         EGGM- - -
 
 
O O O    r   r!   c                 2    d| vrd| z   } t          |           S )N.zjsonschema.r   )names    r   _resolve_name_with_defaultrh      s#    
$t#r   zJSON Schema Validation CLI)descriptionz-iz
--instanceappend	instancesz
        a path to a JSON instance (i.e. filename.json) to validate (may
        be specified multiple times). If no instances are provided via this
        option, one will be expected on standard input.
    )actiondesthelpz-Fz--error-formata  
        the format to use for each validation error message, specified
        in a form suitable for str.format. This string will be passed
        one formatted object named 'error' for each ValidationError.
        Only provide this option when using --output=plain, which is the
        default. If this argument is unprovided and --output=plain is
        used, a simple default representation will be used.
    )rn   z-oz--outputr   r   z
        an output format to use. 'plain' (default) will produce minimal
        text with one line for each error, while 'pretty' will produce
        more detailed human-readable output on multiple lines.
    )choicesdefaultrn   z-Vz--validatorz
        the fully qualified object name of a validator to use, or, for
        validators that are registered with jsonschema, simply the name
        of the class.
    )rF   rn   z
--base-uriz
        a base URI to assign to the provided schema, even if it does not
        declare one (via e.g. $id). This option can be used if you wish to
        resolve relative references to a particular URI (or local path)
    z	--versionversion
jsonschema)rl   rq   schemaz=the path to a JSON Schema to validate with (i.e. schema.json)c                     t          t                              | pdg                    }|d         dk    r"|d         rt                              d          |d         dk    r|d         d|d<   |S )Nz--helpargsr   r   r   z3--error-format can only be used with --output plainz"{error.instance}: {error.message}
)varsparser
parse_argsr3   )rv   r$   s     r   ry   ry      s    V&&D,>XJ&??@@Ig%%)N*C%llA
 
 	
 g%%)N*C*K$I	.!r   c                     d}|                     |          D ]}d}|                    | |           |s|                    |            |S )NFTrW   r3   )rW   )iter_errorsr>   rA   )rW   instance	validator	outputterinvalidr3   s         r   _validate_instancer      sl    G&&x00 M M""e"LLLL B$$=$AAANr   r_   c                 f    t          j        t          t          |                                d S )Nru   )r$   )r-   exitrunry   ru   s    r   mainr      s.    HS:400011122222r   c                 ~   t                               | ||          	                     | d                   }n# t          $ r Y dS w xY w| d         }|t	          |          }	 |                    |           n5# t          $ r(}                    | d         |           Y d }~dS d }~ww xY w| d         rj        | d         }}n	fd}dg}| d	         t          | d	         |
          nd }	 |||	          }
d}|D ]6}	  ||          }|t          |||
          z  }%# t          $ r d}Y 3w xY w|S )N)r$   r   r    rs   r_   r~   r{   rk   c                     	 t          j                  S # t          $ r<}                    dt	          j                               t                      |d }~ww xY w)Nr^   r'   )r.   r/   r   r0   r-   r)   r   )_r3   r   stdins     r   r/   zrun.<locals>.load
  so    3y'''" 3 3 3''"S\^^ (    &''U2	3s    
A7AAr^   base_uri)r   referrer)resolverr   )rW   r}   r~   r   )
r   r%   r/   r   r   check_schemar
   r>   r   r   )r$   r   r    r   rs   	Validatorr3   r/   rk   r   r~   	exit_codeeachr}   r   s      `          @r   r   r      s   )) *  I	( 344   qq +&I!&))	v&&&&   ""#H- 	# 	
 	
 	
 qqqqq   #.)K*@i	3 	3 	3 	3 	3 	3 K	
 
:		* :&    15 
 	&8444II  
	tDzzH +"!##	   II  	 	 	III	 s9   = 
A
A(A> >
B0B++B0	D++D:9D:)+__doc__	importlibr   r.   r   textwrapr   argparser-   rN   warningspkgutilr   ImportErrorpkgutil_resolve_nameattrsr   r	   jsonschema.exceptionsr
   jsonschema.validatorsr   r   warnDeprecationWarning	Exceptionr   r   r"   r!   rh   ArgumentParserrx   add_argumentrq   ry   r   argvr   r   r    r   r   r   r   r   <module>r      s                              



     2$$$$$$$ 2 2 2111111112          - - - - - - = = = = = = = = 	:    	 	 	 	 	i 	 	 	 &I &I &I &I &I &I &I &IR &< &< &< &< &< &< &< &<R        (   
!	 ,
 
 
   ,	
	  	 	 	   

  
 
 
   *h
	  	 	 	   -	#
       
       H\**    
   	H         hqrrl 3 3 3 3 *SZsy : : : : : :s   1 ??