
    {g                         S r SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK	r	SSK
r
 SSKJr  SSKJrJr  SSKJr  SS	KJrJr  \
R.                  " S
\SS9   " S S\5      r\ " S S5      5       r\ " S S5      5       r\ " S S5      5       rS r\R>                  " SS9r \ RC                  SSSSSS9  \ RC                  SSS S!9  \ RC                  S"S#S$S%/S$S&S'9  \ RC                  S(S)\S*S+9  \ RC                  S,S-S!9  \ RC                  S.S/\RD                  " S05      S19  \ RC                  S2S3S!9  S4 r#S5 r$\RJ                  S6S 4S7 jr&\RN                  \RP                  \RR                  4S8 jr*g! \ a
    SSKJr   GNNf = f)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                       \ rS rSrSrg)_CannotLoadFile#    N)__name__
__module____qualname____firstlineno____static_attributes__r       0/usr/lib/python3/dist-packages/jsonschema/cli.pyr   r   #   s    r   r   c                   l    \ rS rSr\" 5       r\" 5       r\" 5       r\S 5       r	S r
S rS rS rS rSrg	)

_Outputter'   c                 f    US   S:X  a  [        US   5      nOUS   S:X  a
  [        5       nU " WX#S9$ )Noutputplainerror_formatpretty)	formatterstdoutstderr)_PlainFormatter_PrettyFormatter)cls	argumentsr#   r$   r"   s        r   from_arguments_Outputter.from_arguments.   s@    X')'	.(ABIx H,(*IYvEEr   c                 n    [        U5      nU    [        R                  " U5      sS S S 5        $ ! [         a.    U R                  U[        R                  " 5       S9  [        5       ef = f! [         a.    U R                  U[        R                  " 5       S9  [        5       ef = f! , (       d  f       g = f)Npathexc_info)
openFileNotFoundErrorfilenotfound_errorsysr.   r   jsonloadr   parsing_error)selfr-   files      r   r4   _Outputter.load6   s    	$:D
 (yy T	 ! 	$###G!##	$ # (""s||~"F%''( Ts%   0 B&A+8A(+8B##B&&
B4c                 n    U R                   R                  U R                  R                  " S0 UD65        g Nr   )_stderrwrite
_formatterr1   r6   kwargss     r   r1   _Outputter.filenotfound_errorD   &    4??==GGHr   c                 n    U R                   R                  U R                  R                  " S0 UD65        g r:   )r;   r<   r=   r5   r>   s     r   r5   _Outputter.parsing_errorG   s&    4??88B6BCr   c                 n    U R                   R                  U R                  R                  " S0 UD65        g r:   )r;   r<   r=   validation_errorr>   s     r   rE   _Outputter.validation_errorJ   s&    4??;;EfEFr   c                 n    U R                   R                  U R                  R                  " S0 UD65        g r:   )_stdoutr<   r=   validation_successr>   s     r   rI   _Outputter.validation_successM   rA   r   r   N)r   r   r   r   r	   r=   rH   r;   classmethodr)   r4   r1   r5   rE   rI   r   r   r   r   r   r   '   sJ     JgGgGF F(IDGIr   r   c                   @    \ rS rSr\" S5      rSrS rS rS r	S r
Srg	)
r&   Q   z`        ===[{type}]===({path})===

        {body}
        -----------------------------
        z===[SUCCESS]===({path})===
c                 V    U R                   R                  USSR                  U5      S9$ )Nr0   z{!r} does not exist.r-   typebody)
_ERROR_MSGformatr6   r-   r.   s      r   r1   #_PrettyFormatter.filenotfound_error^   s2    %%$'..t4 & 
 	
r   c                     Uu  p4nSR                  [        R                  " X4U5      5      nU R                  R	                  UUR
                  US9$ )N rO   )join	tracebackformat_exceptionrR   rS   r   )r6   r-   r.   exc_type	exc_valueexc_traceback	exc_liness          r   r5   _PrettyFormatter.parsing_errore   sW    -5*]GG&&xMJ
	 %%"" & 
 	
r   c                 `    U R                   R                  UUR                  R                  US9$ )NrO   )rR   rS   	__class__r   r6   instance_patherrors      r   rE   !_PrettyFormatter.validation_errorp   s1    %%)) & 
 	
r   c                 4    U R                   R                  US9$ )N)r-   )_SUCCESS_MSGrS   r6   rc   s     r   rI   #_PrettyFormatter.validation_successw   s      '']';;r   r   N)r   r   r   r   r   rR   rg   r1   r5   rE   rI   r   r   r   r   r&   r&   Q   s.     	J 2L
	

<r   r&   c                   :    \ rS rSr\" 5       rS rS rS rS r	Sr
g)r%   {   c                 $    SR                  U5      $ )Nz{!r} does not exist.
)rS   rT   s      r   r1   "_PlainFormatter.filenotfound_error   s    '..t44r   c                 N    SR                  US:X  a  SO
[        U5      US   5      $ )NzFailed to parse {}: {}
<stdin>   )rS   reprrT   s      r   r5   _PlainFormatter.parsing_error   s,    )00*IT
QK
 	
r   c                 4    U R                   R                  XS9$ )N)	file_namerd   )_error_formatrS   rb   s      r   rE    _PlainFormatter.validation_error   s    !!((=(NNr   c                     g)NrW   r   rh   s     r   rI   "_PlainFormatter.validation_success   s    r   r   N)r   r   r   r   r	   ru   r1   r5   rE   rI   r   r   r   r   r%   r%   {   s      GM5
Or   r%   c                 .    SU ;  a  SU -   n [        U 5      $ )N.zjsonschema.r   )names    r   _resolve_name_with_defaultr|      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.
    )r   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defaultr   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.
    )rP   r   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)r   r   schemaz=the path to a JSON Schema to validate with (i.e. schema.json)c                     [        [        R                  U =(       d    S/S95      nUS   S:w  a  US   (       a  [        R                  S5      eUS   S:X  a  US   c  SUS'   U$ )Nz--helpargsr   r   r    z3--error-format can only be used with --output plainz"{error.instance}: {error.message}
)varsparser
parse_argsrd   )r   r(   s     r   r   r      sr    V&&D,>XJ&?@Ig%)N*CllA
 	
 g%)N*C*K$I	.!r   c                     SnUR                  U5       H  nSnUR                  XS9  M     U(       d  UR                  U S9  U$ )NFTrc   rd   )rc   )iter_errorsrE   rI   )rc   instance	validator	outputterinvalidrd   s         r   _validate_instancer      sM    G&&x0"""L 1 $$=$ANr   rp   c                 L    [         R                  " [        [        U S9S95        g )Nr   )r(   )r2   exitrunr   r   s    r   mainr      s    HHS:4012r   c           	        ^^ [         R                  U UUS9m TR                  U S   5      nU S   nUc  [	        U5      n UR                  U5        U S   (       a  TR                  U S   pO
UU4S jnS/nU S	   b  [        U S	   US
9OS n	U" XIS9n
SnU H  n U" U5      nU[        UUU
TS9-  nM     U$ ! [         a     gf = f! [         a  nTR                  U S   US9   S nAgS nAff = f! [         a    Sn Mj  f = f)N)r(   r#   r$   r   rp   r   r   r   c                    >  [         R                  " T5      $ ! [         a.    TR                  S[        R
                  " 5       S9  [        5       ef = f)Nro   r,   )r3   r4   r   r5   r2   r.   r   )_r   stdins    r   r4   run.<locals>.load
  sO    (yy''" (''"S\\^ (  &''	(s	    8Aro   base_uri)r   referrer)resolverr   )rc   r   r   r   )
r   r)   r4   r   r   check_schemar
   rE   r   r   )r(   r#   r$   r   r   	Validatorrd   r4   r   r   r   	exit_codeeachr   r   s      `          @r   r   r      sk   )) * I	( 34 +&I!&)	v& #..)K*@i	( K	
 
:		* :& 15 
 &4II
	DzH +"!##	 I  c    ""#H- 	# 	
 <  	I	s;   B7 C C17
CC
C.C))C.1D D)+__doc__	importlibr   r3   r   textwrapr   argparser2   rY   warningspkgutilr   ImportErrorpkgutil_resolve_nameattrsr   r	   jsonschema.exceptionsr
   jsonschema.validatorsr   r   warnDeprecationWarning	Exceptionr   r   r&   r%   r|   ArgumentParserr   add_argumentr   r   r   argvr   r#   r$   r   r   r   r   r   <module>r      s         
  2$   - = 	: 	i 	 &I &I &IR &< &< &<R   ( 
	 	 ,
   ,	
	  	   

  
   *h
	  	   -	#
     
     \*  
   	H   hhqrl 3 **SZZsyy :}  2112s   E/ /E?>E?