o
    w¨Êh”  ã                   @   sÈ   d Z ddlmZ ddlmZ ddlmZmZ ddlmZ	 ddl
mZ ddlmZ ddlmZ dZdZdZd	ZG d
d„ deƒZG dd„ deƒZG dd„ deƒZdd„ Zeee	jƒZeee	jƒZdd„ ZdS )zÎ
    pyexcel_io.plugins
    ~~~~~~~~~~~~~~~~~~~

    factory for getting readers and writers

    :copyright: (c) 2014-2017 by Onni Software Ltd.
    :license: New BSD License, see LICENSE for more details
é    ©Úscan_plugins_regex)ÚPluginManager)ÚPluginInfoChainÚ
PluginInfoNz,one of these plugins for %s data in '%s': %szHPlease upgrade the plugin '%s' according to plugin compactibility table.zpyexcel-io readerzpyexcel-io writerc                   @   s   e Zd ZdZdd„ ZdS )ÚIOPluginInfoz"Pyexcel-io plugin info descriptionc                 c   s   � | j D ]}|V  qd S ©N)Ú
file_types)ÚselfÚ	file_type© r   úD/var/www/html/env/lib/python3.10/site-packages/pyexcel_io/plugins.pyÚtags   s   €
ÿzIOPluginInfo.tagsN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    r   c                   @   s0   e Zd ZdZ			ddd„Z			ddd„ZdS )ÚIOPluginInfoChainz6provide custom functions to add a reader and a writer Nc                 C   ó    t t|  |¡||d�}|  |¡S )z# add pyexcle-io reader plugin info ©r	   Ústream_type)r   ÚREADER_PLUGINÚ_get_abs_pathÚadd_a_plugin_instance©r
   Úrelative_plugin_class_pathr	   r   Úa_plugin_infor   r   r   Úadd_a_reader&   ó   ü
zIOPluginInfoChain.add_a_readerc                 C   r   )z# add pyexcle-io writer plugin info r   )r   ÚWRITER_PLUGINr   r   r   r   r   r   Úadd_a_writer5   r   zIOPluginInfoChain.add_a_writer)NNN)r   r   r   r   r   r    r   r   r   r   r   #   s    
üür   c                   @   sB   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	d
„Zdd„ Zdd„ Z	dS )Ú	IOManagerzManage pyexcel-io pluginsc                 C   s0   t  | |¡ || _d| _| jtkrd| _d S d S )NÚreadÚwrite)r   Ú__init__Úknown_pluginsÚactionÚplugin_namer   )r
   Úplugin_typeÚ
known_listr   r   r   r$   H   s   

ÿzIOManager.__init__c                 C   s   t  | |¡ t|ƒ d S r   )r   Úload_me_laterÚ_do_additional_registration)r
   Úplugin_infor   r   r   r*   O   s   zIOManager.load_me_laterc                 C   s   t  | ||¡ t|ƒ dS )z for dynamically loaded plugin N)r   Úregister_a_pluginr+   )r
   Úclsr,   r   r   r   r-   S   s   zIOManager.register_a_pluginNc                 K   s*   |  ¡ }| j||d�}|ƒ }| |¡ |S )N)Úlibrary)ÚlowerÚload_me_nowÚset_type)r
   r   r/   ÚkeywordsÚ_IOManager__file_typeÚpluginÚhandlerr   r   r   Úget_a_pluginX   s
   
zIOManager.get_a_pluginc                 C   sb   | j  |d ¡}|r*d}t|ƒdkr|t| j|d |¡f 7 }n||d 7 }t |¡‚t d| ¡‚)NzPlease install é   ú,r   z No suitable library found for %s)	r%   ÚgetÚlenÚERROR_MESSAGE_FORMATTERr&   ÚjoinÚ
exceptionsÚ(SupportingPluginAvailableButNotInstalledÚNoSupportingPluginFound)r
   r   ÚpluginsÚmessager   r   r   Úraise_exception_   s   
ý
ÿzIOManager.raise_exceptionc                 C   s:   t t| j ¡ ƒt| j ¡ ƒ ƒ}| t tjtjgƒ¡}|S )z return all supported formats )	ÚsetÚlistÚregistryÚkeysr%   Ú
differenceÚ	constantsÚDB_SQLÚ	DB_DJANGO)r
   Úall_formatsr   r   r   Úget_all_formatsr   s   ÿÿzIOManager.get_all_formats)NN)
r   r   r   r   r$   r*   r-   r7   rC   rM   r   r   r   r   r!   E   s    
r!   c                 C   s0   |   ¡ D ]}t || j¡ t || jd ¡ qd S r   )r   ÚmanagerÚregister_stream_typer   Úregister_a_file_type)r,   r   r   r   r   r+   }   s   þr+   c                 C   s   t | |||d� dS )z&Try to discover all pyexcel-io plugins)Úplugin_name_patternsÚpyinstaller_pathÚ
black_listÚ
white_listNr   )rQ   ÚpathrS   rT   r   r   r   Úload_plugins‡   s   
ürV   )r   Ú
lml.loaderr   Ú
lml.pluginr   r   r   Úpyexcel_io.utilsÚutilsÚioutilsÚpyexcel_io.managerrN   Úpyexcel_io.exceptionsr>   Úpyexcel_io.constantsrI   r<   ÚUPGRADE_MESSAGEr   r   r   r   r!   r+   ÚAVAILABLE_READERSÚREADERSÚAVAILABLE_WRITERSÚWRITERSrV   r   r   r   r   Ú<module>   s&    	"8