
    Fh                       S r SSKJr  SSKrSSKJrJr  SSKJrJ	r	  SSK
JrJr  SSKJr  SSKJr   SS	KJr  S
SKJr  S
SKJrJr   " S S\5      r " S S\5      r " S S\5      r\	\\\4   \\4   r " S S5      rg! \ a    \r NQf = f)zEvent schema objects.    )annotationsN)PathPurePath)AnyUnion)FormatChecker
validators)Registry)DRAFT7)	Validator   )yaml)draft7_format_checkervalidate_schemac                      \ rS rSrSrSrg)EventSchemaUnrecognized   z*An error for an unrecognized event schema. N__name__
__module____qualname____firstlineno____doc____static_attributes__r       hC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\jupyter_events/schema.pyr   r      s    4r   r   c                      \ rS rSrSrSrg)EventSchemaLoadingError   z+An error for an event schema loading error.r   Nr   r   r   r   r   r      s    5r   r   c                      \ rS rSrSrSrg)EventSchemaFileAbsent   z)An error for an absent event schema file.r   Nr   r   r   r   r"   r"      s    3r   r"   c                      \ rS rSrSr\R                  \S4       SS jjrSS jr	\
SSS jj5       r\
SS j5       r\SS j5       r\SS	 j5       r\SS
 j5       rSS jrSrg)EventSchema$   a9  A validated schema that can be used.

On instantiation, validate the schema against
Jupyter Event's metaschema.

Parameters
----------
schema: dict or str
    JSON schema to validate against Jupyter Events.

validator_class: jsonschema.validators
    The validator class from jsonschema used to validate instances
    of this event schema. The schema itself will be validated
    against Jupyter Event's metaschema to ensure that
    any schema registered here follows the expected form
    of Jupyter Events.

registry:
    Registry for nested JSON schema references.
Nc                    U R                  U5      n[        U5        Uc!  [        R                  " U5      [	        5       -  nU" XTUS9U l        XPl        g)zInitialize an event schema.N)registryformat_checker)_load_schemar   r   create_resourcer
   
_validator_schema)selfschemavalidator_classr)   r(   r-   s         r   __init__EventSchema.__init__:   sO     ##F+ --g6CH *'Ucdr   c                @    [         R                  " U R                  SS9$ )z"A string repr for an event schema.   )indent)jsondumpsr-   r.   s    r   __repr__EventSchema.__repr__M   s    zz$,,q11r   c                    [        U [        5      (       a  gSnSS jnU(       a  U" U 5      (       a  US-  nOUS-  n[        U5      e)z`Ensures schema was correctly loaded into a dictionary. Raises
EventSchemaLoadingError otherwise.Nz/Could not deserialize schema into a dictionary.c                    [        U 5      nUR                  S5      =(       d)    UR                  S5      =(       d    UR                  S5      $ )Nz*.ymlz*.yamlz*.json)r   match)r/   paths     r   intended_as_path9EventSchema._ensure_yaml_loaded.<locals>.intended_as_pathZ   s6    <D::g&V$**X*>V$**XBVVr   zF Paths to schema files must be explicitly wrapped in a Pathlib object.z= Double check the schema and ensure it is in the proper form.)r/   strreturnbool)
isinstancedictr   )r/   was_str	error_msgr?   s       r   _ensure_yaml_loadedEventSchema._ensure_yaml_loadedQ   sP     fd##E		W '//aaIXXI%i00r   c                   [        U [        5      (       a  U $ [        U [        5      (       a\  [        U 5      R	                  5       (       d  SU  S3n[        U5      e[        R                  " U 5      n[        R                  U5        U$ [        U [        5      (       a,  [        R                  " U 5      n[        R                  USS9  U$ SU R                  R                   S3n[        U5      e)zLoad a JSON schema from different sources/data types.

`schema` could be a dictionary or serialized string representing the
schema itself or a Pathlib object representing a schema file on disk.

Returns a dictionary with schema data.
z!Schema file not present at path "z".T)rF   zAExpected a dictionary, string, or PurePath, but instead received .)rD   rE   r   r   existsr"   r   loadr%   rH   rA   loads	__class__r   r   )r/   msgloaded_schemas      r   r*   EventSchema._load_schemag   s     fd##M fh''<&&((9&D+C00 IIf-M++M:   fc"" JJv.M++M4+H  QRXRbRbRkRkQllmn%c**r   c                     U R                   S   $ )zSchema $id field.z$idr-   r8   s    r   idEventSchema.id   s     ||E""r   c                     U R                   S   $ )zSchema's version.versionrT   r8   s    r   rX   EventSchema.version   s     ||I&&r   c                     U R                   S   $ )N
propertiesrT   r8   s    r   r[   EventSchema.properties   s    ||L))r   c                :    U R                   R                  U5        g)z3Validate an incoming instance of this event schema.N)r,   validate)r.   datas     r   r^   EventSchema.validate   s      &r   )r-   r,   )r/   
SchemaTyper0   ztype[Validator]r)   r   r(   zRegistry[Any] | None)rB   rA   )F)r/   ra   rF   rC   rB   None)r/   ra   rB   dict[str, Any])rB   int)rB   rc   )r_   rc   rB   rb   )r   r   r   r   r   r	   Draft7Validatorr   r1   r9   staticmethodrH   r*   propertyrU   rX   r[   r^   r   r   r   r   r%   r%   $   s    0 ,6+E+E(=)- ) &	
 '&2 1 1* + +B # # ' ' * *'r   r%   ) r   
__future__r   r6   pathlibr   r   typingr   r   
jsonschemar   r	   referencingr
   referencing.jsonschemar   jsonschema.protocolsr   ImportError r   r   r   	Exceptionr   r   r"   rE   rA   ra   r%   r   r   r   <module>rr      s     "  "  0   ).  >5i 56i 64I 4 4S>301
u' u'-  Is   A? ?B
	B
