a
    ¡˜ëjÕ  ã                   @  s¬   d Z ddlmZ ddlZddlmZ ejr>ddlmZ e	e Z
i Zdddd	œd
d„Zejddœddddœdd„ƒZejddœddddœdd„ƒZddœddddœdd„ZdS )a!  A registry of :class:`Schema <marshmallow.Schema>` classes. This allows for string
lookup of schemas, which may be used with
class:`fields.Nested <marshmallow.fields.Nested>`.

.. warning::

    This module is treated as private API.
    Users should not need to use this module directly.
é    )ÚannotationsN)ÚRegistryError)ÚSchemaÚstrÚ
SchemaTypeÚNone)Ú	classnameÚclsÚreturnc                   s‚   |j ‰ ˆ › d| › �}| tv rFt‡ fdd„t|  D ƒƒsFt|   |¡ n| tvrX|gt| < |tvrtt |g ¡ |¡ n
|gt|< dS )a¤  Add a class to the registry of serializer classes. When a class is
    registered, an entry for both its classname and its full, module-qualified
    path are added to the registry.

    Example: ::

        class MyClass:
            pass


        register("MyClass", MyClass)
        # Registry:
        # {
        #   'MyClass': [path.to.MyClass],
        #   'path.to.MyClass': [path.to.MyClass],
        # }

    Ú.c                 3  s   | ]}|j ˆ kV  qd S ©N)Ú
__module__)Ú.0Zeach©Úmodule© úY/mnt/bigstor/www/usecases/.venv/lib/python3.9/site-packages/marshmallow/class_registry.pyÚ	<genexpr>9   s   zregister.<locals>.<genexpr>N)r   Ú	_registryÚanyÚappendÚ
setdefault)r   r	   Úfullpathr   r   r   Úregister   s    ÿ
r   .)Úallztyping.Literal[False])r   r   r
   c                C  s   d S r   r   ©r   r   r   r   r   Ú	get_classH   s    r   ztyping.Literal[True]zlist[SchemaType]c                C  s   d S r   r   r   r   r   r   r   L   s    FÚboolzlist[SchemaType] | SchemaTypec             
   C  sx   zt |  }W n6 tyB } ztd| ›d�ƒ|‚W Y d}~n
d}~0 0 t|ƒdkrl|r\t |  S td| ›d�ƒ‚t |  d S )z½Retrieve a class from the registry.

    :raises: `marshmallow.exceptions.RegistryError` if the class cannot be found
        or if there are multiple entries for the given class name.
    zClass with name z1 was not found. You may need to import the class.Né   zMultiple classes with name z8 were found. Please use the full, module-qualified path.r   )r   ÚKeyErrorr   Úlen)r   r   ÚclassesÚerrorr   r   r   r   R   s    
ÿý
ÿ)Ú__doc__Ú
__future__r   ÚtypingZmarshmallow.exceptionsr   ÚTYPE_CHECKINGZmarshmallowr   Útyper   r   r   Úoverloadr   r   r   r   r   Ú<module>   s   *ÿ