
    ^h
                    V    S r SSKJr  SSKJr  SSKJr   " S S\5      r " S S	5      r	g
)z"An event schema registry.    )annotations)Any   )EventSchemac                      \ rS rSrSrSrg)SchemaRegistryException	   z:Exception class for Jupyter Events Schema Registry Errors. N)__name__
__module____qualname____firstlineno____doc____static_attributes__r
       X/home/james-whalen/.local/lib/python3.13/site-packages/jupyter_events/schema_registry.pyr   r   	   s    Dr   r   c                      \ rS rSrSrSSS jjrSS jrSS jrSS jr\	SS j5       r
SS	 jrSS
 jrSS jrSS jrSrg)SchemaRegistry   z>A convenient API for storing and searching a group of schemas.Nc                $    U=(       d    0 U l         g)zInitialize the registry.N_schemas)selfschemass     r   __init__SchemaRegistry.__init__   s    072r   c                    XR                   ;   $ )z:Syntax sugar to check if a schema is found in the registryr   )r   keys     r   __contains__SchemaRegistry.__contains__   s    mm##r   c                    SR                  U R                  R                  5        Vs/ s H  n[        U5      PM     sn5      $ s  snf )zThe str repr of the registry.z,
)joinr   valuesstr)r   ss     r   __repr__SchemaRegistry.__repr__   s6    zz4==+?+?+AB+Aa3q6+ABCCBs   Ac                    UR                   U R                  ;   a  SUR                    S3n[        U5      eXR                  UR                   '   g )NzThe schema, zB, is already registered. Try removing it and registering it again.)idr   r   )r   
schema_objmsgs      r   _addSchemaRegistry._add   sK    ==DMM)z}}o .H H  *#..'1jmm$r   c                H    [        U R                  R                  5       5      $ N)listr   keys)r   s    r   
schema_idsSchemaRegistry.schema_ids%   s    DMM&&())r   c                h    [        U[        5      (       d  [        U5      nU R                  U5        U$ )zrAdd a valid schema to the registry.

All schemas are validated against the Jupyter Events meta-schema
found here:
)
isinstancer   r,   )r   schemas     r   registerSchemaRegistry.register)   s,     &+.. (F		&r   c                b     U R                   U   $ ! [         a    SU S3n[        U5      Sef = f)zNFetch a given schema. If the schema is not found,
this will raise a KeyError.
The requested schema, R, was not found in the schema registry. Are you sure it was previously registered?Nr   KeyErrorr   id_r+   s      r   getSchemaRegistry.get4   sK    	*==%% 	*( .N N  3-T)	*s    .c                `     U R                   U	 g! [         a    SU S3n[        U5      Sef = f)zORemove a given schema. If the schema is not found,
this will raise a KeyError.
r:   r;   Nr<   r>   s      r   removeSchemaRegistry.removeA   sH    	*c" 	*( .N N  3-T)	*s    -c                H    U R                  U5      nUR                  U5        g)z9Validate an event against a schema within this
registry.
N)r@   validate)r   r?   datar6   s       r   validate_eventSchemaRegistry.validate_eventN   s     #r   r   r/   )r   zdict[str, EventSchema] | None)r   r$   returnbool)rJ   r$   )r*   r   rJ   None)rJ   z	list[str])r6   z$dict[str, Any] | (str | EventSchema)rJ   r   )r?   r$   rJ   r   )r?   r$   rJ   rL   )r?   r$   rG   zdict[str, Any]rJ   rL   )r   r   r   r   r   r   r   r&   r,   propertyr2   r7   r@   rC   rH   r   r
   r   r   r   r      sB    H>$D2 * *	**r   r   N)
r   
__future__r   typingr   r6   r   	Exceptionr   r   r
   r   r   <module>rQ      s+      "  Ei EF Fr   