
    He              	           d 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 ddl	m
Z
 ddlmZ ddlmZ ddlmZ dd	lmZmZmZ  ej                    d
k    Z G d d          Z G d d          Z e            Z ed          Z ej                     ej                    dd                        Z ej                     ej        d          ej         dej!        de"de#fd                                    Z$e%                    e$           dS )zThe cli for jupyter events.    N)ValidationError)Console)JSON)escape)Padding)Style)EventSchemaEventSchemaFileAbsentEventSchemaLoadingErrorWindowsc                   "    e Zd ZdZdZdZdZdZdS )RCzReturn code enum.r            N)__name__
__module____qualname____doc__OKINVALID
UNPARSABLE	NOT_FOUND     2lib/python3.11/site-packages/jupyter_events/cli.pyr   r      s(        	
BGJIIIr   r   c                   *    e Zd ZdZerdndZerdndZdS )EMOJIzTerminal emoji enumXXu   ❌r   u   ✔N)r   r   r   r   WINXr   r   r   r   r   r      s0        !A	"(BBBr   r   T)stderrreturnc                      dS )a  A simple CLI tool to quickly validate JSON schemas against
    Jupyter Event's custom validator.

    You can see Jupyter Event's meta-schema here:

        https://raw.githubusercontent.com/jupyter/jupyter_events/main/jupyter_events/schemas/event-metaschema.yml
    Nr   r   r   r   mainr%   '   s	     	Dr   schemactxc                 2   t                               dt          d                     d}	 t          j        |          }n# t
          $ r Y nw xY w|t          j        |          }	 t          j        |          }nZ# t
          t          f$ rF}t          
                    d|            |                     t          j                  cY d}~S d}~ww xY wt          t          j        |                    }t           
                    t#          |d                     	 t          |           t                               dt          d	                     t#          d
t$          j         dd          }t           
                    |           |                     t          j                  S # t(          $ r}t                              dt          d                     t          
                    dt$          j         d           t          
                    d           t-          t/          |                    }t          
                    t#          |d                     |                     t          j                  cY d}~S d}~ww xY w)zzValidate a SCHEMA against Jupyter Event's meta schema.

    SCHEMA can be a JSON/YAML string or filepath to a schema.
    zValidating the following schemablue)color)styleNz[bold red]ERROR[/]: )r   r   r      Resultsgreenz[green]z([white] Nice work! This schema is valid.)r   r   r   r   redz[red]z& [white]The schema failed to validate.z/
We found the following error with your schema:)consoleruler   r	   _load_schemar   pathlibPathr
   error_consoleprintexitr   r   r   jsondumpsr   r   r   r   r!   r   strr   )r'   r&   _schemaschema_patheschema_jsonouterrs           r   validaterA   4   sq    LL2%f:M:M:MLNNNG*622"    	 l6**	+!.{;;GG')>? 	+ 	+ 	+  :q : :;;;88BM********		+ tz'**++KMM'+|44555$GYe'&:&:&:;;;RRRRT`aacxx $ $ $9E,>,>,>???SEGSSSTTTNOOOSXXGC66777xx
########$sO   A 
AA*A? ?C;CCC#BF3 3
J=CJJJ)r#   N)&r   r8   r3   platformclick
jsonschemar   rich.consoler   	rich.jsonr   rich.markupr   rich.paddingr   
rich.styler   jupyter_events.schemar	   r
   r   systemr    r   r   r0   r5   groupversion_optionr%   commandargumentpass_contextContextr:   intrA   add_commandr   r   r   <module>rT      s   ! !     & & & & & &                                           ] ] ] ] ] ] ] ] ] ]ho9$       # # # # # # # # '))t$$$ 	 	 	  	 +$%- +$ +$ +$ +$ +$   +$\        r   