U
    ±[Öe¡  ã                   @   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Zd	d
ddddddedddddiZG dd„ deƒZdd„ ZdS )z¼
    pyexcel.plugins.sources.http
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Representation of http sources

    :copyright: (c) 2015-2022 by Onni Software Ltd.
    :license: New BSD License
é    )Ú	constants)ÚAbstractSource)ÚPY2Úrequest)ÚPARSERé   )ÚparamszAapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetztext/csvÚcsvztext/tab-separated-valuesZtsvz.application/vnd.oasis.opendocument.spreadsheetZodszapplication/vnd.ms-excelZxlsZxlsxz.application/vnd.ms-excel.sheet.macroenabled.12Zxlsmz	text/htmlÚhtmlc                   @   sT   e Zd ZdZejgZejej	fZ
ejfZejgZejZd	dd„Zdd„ Zdd„ ZdS )
Ú
HttpSourcez6
    Multiple sheet data source via http protocol
    Nc                 K   s   || _ tj| f|Ž d S ©N)Ú_HttpSource__urlr   Ú__init__)ÚselfÚurlÚkeywords© r   ú^/var/www/html/services/stratfitenv/lib/python3.8/site-packages/pyexcel/plugins/sources/http.pyr   *   s    zHttpSource.__init__c           	      C   s|   t  | j¡}| ¡ }tr |j}n| ¡ }t |d ¡}|d krFt	| jƒ}| j
 dd ¡}t ||¡}| ¡ }|j|f| j
Ž}|S )NÚparser_library)r   Úurlopenr   Úinfor   ÚtypeÚget_content_typeÚFILE_TYPE_MIME_TABLEÚgetÚ_get_file_type_from_urlZ	_keywordsr   Zget_a_pluginÚreadZparse_file_content)	r   Ú
connectionr   Z	mime_typeÚ	file_typer   ZaparserÚcontentZsheetsr   r   r   Úget_data.   s    
zHttpSource.get_datac                 C   s
   | j d fS r   )r   )r   r   r   r   Úget_source_info>   s    zHttpSource.get_source_info)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚURLÚfieldsr   ZSHEETZBOOKÚtargetsZREAD_ACTIONÚactionsÚ
attributesÚkeyr   r    r!   r   r   r   r   r      s   
r   c                 C   s   |   d¡}|d S )NÚ.éÿÿÿÿ)Úsplit)r   Ú	extensionr   r   r   r   B   s    
r   N)r%   Zpyexcelr   Zpyexcel.sourcer   Zpyexcel._compactr   r   Zpyexcel.internalr   Ú r   ZXLSXr   r   r   r   r   r   r   Ú<module>   s.   	       ù#