U
    ±[Öe‹  ã                   @   sx  d Z ddl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mZmZ ddlmZ dd	lmZ d
ZdZeejƒdd„ ƒZeejƒdd„ ƒZeejƒdd„ ƒZeejƒdd„ ƒZeejƒdd„ ƒZeej ƒdd„ ƒZ!eej"ƒdd„ ƒZ#eej$ƒdd„ ƒZ%eej&ƒd*dd„ƒZ'eej(ƒd+dd„ƒZ)eej*ƒd d!„ ƒZ+eej,ƒd,d"d#„ƒZ-eej.ƒd$d%„ ƒZ/d&d'„ Z0d(d)„ Z1dS )-z¨
    pyexcel.core
    ~~~~~~~~~~~~~~~~~~~

    A list of pyexcel signature functions

    :copyright: (c) 2015-2022 by Onni Software Ltd.
    :license: New BSD License
é    N)Ú	constants)Ú
docstrings)ÚBookÚto_book)ÚSheet)ÚOrderedDictÚ
append_docÚzip_longest)Úcore)Úmanagerz
^dest_(.*)z^This function does not accept parameters for pyexce.Sheet. Please use pyexcel.save_as instead.c                  K   sH   i }t jD ]}|| kr
|  |¡||< q
tjf | Ž}t|j|jf|Ž}|S )z@
    Get an instance of :class:`Sheet` from an excel source
    )r   ÚVALID_SHEET_PARAMETERSÚpopÚsourcesÚget_sheet_streamr   ÚpayloadÚname)ÚkeywordsÚsheet_paramsÚfieldZnamed_contentÚsheet© r   úN/var/www/html/services/stratfitenv/lib/python3.8/site-packages/pyexcel/core.pyÚ	get_sheet   s    
r   c                  K   s&   t jf | Ž}t| ¡ |j|jd}|S )z?
    Get an instance of :class:`Book` from an excel source
    )ÚfilenameÚpath)r   Úget_book_streamr   Úto_dictr   r   )r   Zbook_streamÚbookr   r   r   Úget_book*   s    ýr   c                  K   s   t jf ddi| —ŽS )z¢
    Get an instance of :class:`BookStream` from an excel source

    First use case is to get all sheet names without extracting
    the sheets into memory.
    Ú	on_demandT)r   r   )r   r   r   r   Ú	iget_book8   s    r    c                  K   st   t f | Ž\}}i }tjD ]}||kr| |¡||< qtjf |Ž}|j}d|krV|d }t|j|f|Ž}tj	|f|ŽS )z8
    Save a sheet from a data source to another one
    Ú
sheet_name)
Ú_split_keywordsr   r   r   r   r   r   r   r   Ú
save_sheet)r   Údest_keywordsÚsource_keywordsr   r   Úsheet_streamZoutput_sheet_namer   r   r   r   Úsave_asC   s    
r'   c                  K   s^   t f | Ž\}}tjD ]}||krttƒ‚qtjf ddi|—Ž}d|krP|d |_tj|f|ŽS )zá
    Save a sheet from a data source to another one with less memory

    It is simliar to :meth:`pyexcel.save_as` except that it does
    not accept parameters for :class:`pyexcel.Sheet`. And it read
    when it writes.
    r   Tr!   )	r"   r   r   Ú	ExceptionÚSAVE_AS_EXCEPTIONr   r   r   r#   )r   r$   r%   r   r   r   r   r   Úisave_asU   s    	


r*   c                  K   s0   t f | Ž\}}tjf |Ž}t|ƒ}tj|f|ŽS )z7
    Save a book from a data source to another one
    )r"   r   r   r   Ú	save_book©r   r$   r%   r   r   r   r   Úsave_book_ash   s    r-   c                  K   s0   t f | Ž\}}tjf ddi|—Ž}tj|f|ŽS )zÚ
    Save a book from a data source to another one

    It is simliar to :meth:`pyexcel.save_book_as` but it read
    when it writes. This function provide some speedup but
    the output data is not made uniform.
    r   T)r"   r   r   r+   r,   r   r   r   Úisave_book_ass   s    	r.   c                  K   s   t f | Ž}| ¡ S )z‘
    Obtain an array from an excel source

    It accepts the same parameters as :meth:`~pyexcel.get_sheet`
    but return an array instead.
    )r   Zto_array)r   r   r   r   r   Ú	get_array   s    
r/   c                 K   s   t f d| i|—Ž}| ¡ S )a“  
    Obtain a dictionary from an excel source

    It accepts the same parameters as :meth:`~pyexcel.get_sheet`
    but return a dictionary instead.

    Specifically:
    name_columns_by_row : specify a row to be a dictionary key.
    It is default to 0 or first row.

    If you would use a column index 0 instead, you should do::

        get_dict(name_columns_by_row=-1, name_rows_by_column=0)

    Úname_columns_by_row)r   r   ©r0   r   r   r   r   r   Úget_dict   s    r2   c                 K   s   t f d| i|—Ž}t| ¡ ƒS )a¬  
    Obtain a list of records from an excel source

    It accepts the same parameters as :meth:`~pyexcel.get_sheet`
    but return a list of dictionary(records) instead.

    Specifically:
    name_columns_by_row : specify a row to be a dictionary key.
    It is default to 0 or first row.

    If you would use a column index 0 instead, you should do::

        get_records(name_columns_by_row=-1, name_rows_by_column=0)

    r0   )r   ÚlistZ
to_recordsr1   r   r   r   Úget_records¢   s    r4   c                  K   s   t jf ddi| —Ž}|jS )z¤
    Obtain a generator of an two dimensional array from an excel source

    It is similiar to :meth:`pyexcel.get_array` but it has less memory
    footprint.
    r   T)r   r   r   )r   r&   r   r   r   Ú
iget_array·   s    r5   c           	      k   s   t jf ddi|—Ž}d}t|jƒD ]h\}}|dkr8|}q"| rttt||tjdƒ}tƒ }| D ]}|| ||< qZ|V  q"tt||tjdƒV  q"dS )aK  
    Obtain a generator of a list of records from an excel source

    It is similiar to :meth:`pyexcel.get_records` but it has less memory
    footprint but requires the headers to be in the first row. And the
    data matrix should be of equal length. It should consume less memory
    and should work well with large files.
    r   TNr   )Ú	fillvalue)	r   r   Ú	enumerater   Údictr	   r   Z
DEFAULT_NAr   )	Zcustom_headersr   r&   ÚheadersZ	row_indexÚrowZtmp_dictZordered_dictr   r   r   r   Úiget_recordsÃ   s     
ÿÿr;   c                  K   s   t f | Ž}| ¡ S )z
    Obtain a dictionary of two dimensional arrays

    It accepts the same parameters as :meth:`~pyexcel.get_book`
    but return a dictionary instead.
    )r   r   )r   r   r   r   r   Úget_book_dictã   s    
r<   c                 C   s   t  | ¡}|dkrd}|S )z5
    Return the io stream types, string or bytes
    NÚstring)r   Úget_io_type)Ú	file_typeZio_typer   r   r   r>   ï   s    
r>   c                  K   sN   i }i }|   ¡ D ]4\}}t t|¡}|r<| d¡}|||< q|||< q||fS )Né   )ÚitemsÚreÚmatchÚSTARTS_WITH_DESTÚgroup)r   r$   r%   ÚkeyÚvalueÚresultZ	parameterr   r   r   r"   ù   s    


r"   )r   )r   )N)2Ú__doc__rB   Zpyexcelr   r   ÚdocsZpyexcel.bookr   r   Zpyexcel.sheetr   Zpyexcel._compactr   r   r	   Zpyexcel.internalr
   r   Z
pyexcel_ior   rD   r)   Z	GET_SHEETr   ZGET_BOOKr   Z	IGET_BOOKr    ZSAVE_ASr'   ZISAVE_ASr*   ZSAVE_BOOK_ASr-   ZISAVE_BOOK_ASr.   Z	GET_ARRAYr/   ZGET_DICTr2   ZGET_RECORDSr4   Z
IGET_ARRAYr5   ZIGET_RECORDSr;   ZGET_BOOK_DICTr<   r>   r"   r   r   r   r   Ú<module>   sN   	ÿ












