o
    tf                     @  s  d 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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 dkZG dd dZG dd dZe
 Ze
ddZe e dddZe  e!dej"dddZ#e$e# dS )zThe cli for jupyter events.    )annotationsN)ValidationError)Console)JSON)escape)Padding)Style)EventSchemaEventSchemaFileAbsentEventSchemaLoadingErrorWindowsc                   @  s    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 r   r   [/var/www/html/software/conda/envs/catlas/lib/python3.10/site-packages/jupyter_events/cli.pyr      s    r   c                   @  s,   e Zd ZdZer
dndZerdZdS dZdS )EMOJIzTerminal emoji enumZXXu   ❌r   u   ✔N)r   r   r   r   WINXr   r   r   r   r   r      s    r   T)stderrreturnNonec                   C  s   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   r   main)   s    r!   schemactxclick.Contextstrintc              
   C  s  t jdtddd d}zt|}W n	 ty   Y nw |du rPt|}zt|}W n" ttfyO } zt	
d|  | tjW  Y d}~S d}~ww tt|}t 
t|d z$t| t jdtd	dd td
tj dd}t 
| | tjW S  ty } z3t	jdtddd t	
dtj d t	
d tt|}t	
t|d | tjW  Y d}~S d}~w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      Z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	   Z_load_schemar   pathlibPathr
   error_consoleprintexitr   r   r   jsondumpsr   r   r   r   r   r   r%   r   )r#   r"   Z_schemaZschema_patheZschema_jsonouterrr   r   r   validate5   sB   


r9   )r   r    )r#   r$   r"   r%   r   r&   )%r   
__future__r   r4   r/   platformZclickZ
jsonschemar   Zrich.consoler   Z	rich.jsonr   Zrich.markupr   Zrich.paddingr   Z
rich.styler   Zjupyter_events.schemar	   r
   r   systemr   r   r   r-   r1   groupZversion_optionr!   commandargumentZpass_contextr9   Zadd_commandr   r   r   r   <module>   s4    	

.