U
    4Je                     @   s   d Z ddlZddlmZ ddlmZmZ ddlmZm	Z	 ddl
m
Z
 ddlmZ d	Zed
dddeee ee dddZdS )z5Implementing support for MySQL Authentication Plugins    N)	lru_cache)OptionalType   )NotSupportedErrorProgrammingError)logger)BaseAuthPluginzmysql.connector.plugins
   F)maxsizetyped)plugin_nameauth_plugin_classreturnc              
   C   s   t }| rzVtd| td|  td|  |}|rBt||sH|j}td| t||W S  tk
r } zt	d| W 5 d}~X Y n2 t
k
r } ztd| |W 5 d}~X Y nX td|  d	dS )
a  Return authentication class based on plugin name

    This function returns the class for the authentication plugin plugin_name.
    The returned class is a subclass of BaseAuthPlugin.

    Args:
        plugin_name (str): Authentication plugin name.
        auth_plugin_class (str): Authentication plugin class name.

    Raises:
        NotSupportedError: When plugin_name is not supported.

    Returns:
        Subclass of `BaseAuthPlugin`.
    zpackage: %szplugin_name: %s.zAUTHENTICATION_PLUGIN_CLASS: %sz"Requested Module was not found: %sNzInvalid module name: zAuthentication plugin 'z' is not supported)DEFAULT_PLUGINS_PKGr   info	importlibimport_modulehasattrZAUTHENTICATION_PLUGIN_CLASSgetattrModuleNotFoundErrorwarning
ValueErrorr   r   )r   r   packageZplugin_moduleerr r   B/tmp/pip-unpacked-wheel-7_167w8m/mysql/connector/authentication.pyget_auth_plugin+   s    "r   )N)__doc__r   	functoolsr   typingr   r   errorsr   r   r   Zpluginsr	   r   strr   r   r   r   r   <module>   s   
 