a
    ñ»jO  ã                   @  s`   d dl mZ d dlZd dlmZ d dlmZ dgZddddd	œd
d„Zddddddœdd„Z	dS )é    )ÚannotationsN)ÚIterable)ÚAnyÚlazy_importÚstrzdict[str, Any]r   )ÚnameÚsourceÚ	namespaceÚreturnc                 C  sR   d}|| dkr.|d7 }|t |ƒk sJ dƒ‚qt||d… |d| g|ƒ}t|| ƒS )aN  
    Import ``name`` from ``source`` in ``namespace``.

    There are two use cases:

    - ``name`` is an object defined in ``source``;
    - ``name`` is a submodule of ``source``.

    Neither :func:`__import__` nor :func:`~importlib.import_module` does
    exactly this. :func:`__import__` is closer to the intended behavior.

    r   Ú.é   z%importing from parent isn't supportedN)ÚlenÚ
__import__Úgetattr)r   r   r	   ÚlevelÚmodule© r   ú8E:\soccer\ml_env\Lib\site-packages\websockets/imports.pyÚimport_name   s    r   zdict[str, str] | NoneÚNone)r	   ÚaliasesÚdeprecated_aliasesr
   c                   s¬   ˆ du ri ‰ ˆdu ri ‰t ˆƒ‰t ˆ ƒ‰t ˆƒ‰ˆˆ@ r@J dƒ‚ˆˆ@ rPJ dƒ‚ˆˆ@ r`J dƒ‚ˆd ‰dddœ‡ ‡‡‡fdd„}|ˆd	< d
dœ‡‡‡fdd„}|ˆd< dS )a„  
    Provide lazy, module-level imports.

    Typical use::

        __getattr__, __dir__ = lazy_import(
            globals(),
            aliases={
                "<name>": "<source module>",
                ...
            },
            deprecated_aliases={
                ...,
            }
        )

    This function defines ``__getattr__`` and ``__dir__`` per :pep:`562`.

    Nznamespace conflictÚ__name__r   r   )r   r
   c                   s¤   ˆ d usJ ‚zˆ |  }W n t y*   Y n0 t| |ˆƒS ˆd usDJ ‚zˆ|  }W n t yb   Y n*0 tjˆ› d| › d�tdd� t| |ˆƒS tdˆ›d| ›�ƒ‚d S )Nr   z is deprecatedé   )Ú
stacklevelzmodule z has no attribute )ÚKeyErrorr   ÚwarningsÚwarnÚDeprecationWarningÚAttributeError)r   r   )r   r   r	   Úpackager   r   Ú__getattr__G   s$    ýz lazy_import.<locals>.__getattr__r!   zIterable[str])r
   c                     s   t ˆˆ B ˆB ƒS )N)Úsortedr   )Úaliases_setÚdeprecated_aliases_setÚnamespace_setr   r   Ú__dir__a   s    zlazy_import.<locals>.__dir__r&   )Úset)r	   r   r   r!   r&   r   )r   r#   r   r$   r	   r%   r    r   r       s    )NN)
Ú
__future__r   r   Úcollections.abcr   Útypingr   Ú__all__r   r   r   r   r   r   Ú<module>   s     ý