o
    i                  	   @   s  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 d
kZG dd dZG dd dZe ZeddZe e dd Ze edej dej!de"de#fddZ$e%e$ dS )zThe cli for jupyter events.    N)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UNPARSEABLE	NOT_FOUND r   r   M/var/www/edux/Edux_v2/venv/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 enumXXu   ❌r   u   ✔N)r   r   r   r   WINXr   r   r   r   r   r      s    r   T)stderrc                   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returnc              
   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      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errr   r   r   validate4   sB   


r;   )&r   r2   r-   platformclick
jsonschemar   rich.consoler   	rich.jsonr   rich.markupr   rich.paddingr   
rich.styler   jupyter_events.schemar   r	   r
   systemr   r   r   r*   r/   groupversion_optionr   commandargumentpass_contextContextr4   intr;   add_commandr   r   r   r   <module>   s2    	
.