o
    ‹¨Êhv  ã                   @   s~  d Z ddlZddlmZ ddlmZ ddlmZ ddl	m
  mZ ddlmZmZ ddlmZ ddlmZmZ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j0ƒd d!„ ƒZ1d"d#„ Z2d$d%„ Z3dS )(z¨
    pyexcel.core
    ~~~~~~~~~~~~~~~~~~~

    A list of pyexcel signature functions

    :copyright: (c) 2015-2017 by Onni Software Ltd.
    :license: New BSD License
é    N)ÚBookÚto_book)ÚSheet)ÚOrderedDictÚ
append_docÚzip_longestz
^dest_(.*)z^This function does not accept parameters for pyexce.Sheet. Please use pyexcel.save_as instead.c                  K   sP   i }t jD ]}|| v r|  |¡||< qtjdi | ¤Ž}t|j|jfi |¤Ž}|S )z@
    Get an instance of :class:`Sheet` from an excel source
    N© )Ú	constantsÚVALID_SHEET_PARAMETERSÚpopÚsourcesÚget_sheet_streamr   ÚpayloadÚname)ÚkeywordsÚsheet_paramsÚfieldÚnamed_contentÚsheetr   r   ú>/var/www/html/env/lib/python3.10/site-packages/pyexcel/core.pyÚ	get_sheet   s   
€r   c                  K   s*   t jdi | ¤Ž}t| ¡ |j|jd�}|S )z?
    Get an instance of :class:`Book` from an excel source
    )ÚfilenameÚpathNr   )r   Úget_book_streamr   Úto_dictr   r   )r   Úbook_streamÚbookr   r   r   Úget_book)   s   ýr   c                  K   s   t jd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_demandTNr   )r   r   )r   r   r   r   Ú	iget_book7   s   r   c                  K   s„   t di | ¤Ž\}}i }tjD ]}||v r| |¡||< qtjdi |¤Ž}|j}d|v r/|d }t|j|fi |¤Ž}tj	|fi |¤ŽS )z8
    Save a sheet from a data source to another one
    Ú
sheet_nameNr   )
Ú_split_keywordsr	   r
   r   r   r   r   r   r   Ú
save_sheet)r   Údest_keywordsÚsource_keywordsr   r   Úsheet_streamÚoutput_sheet_namer   r   r   r   Úsave_asB   s   
€r'   c                  K   sf   t di | ¤Ž\}}tjD ]
}||v rttƒ‚qtjdddi|¤Ž}d|v r*|d |_tj|fi |¤Ž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    Nr   )	r!   r	   r
   Ú	ExceptionÚSAVE_AS_EXCEPTIONr   r   r   r"   )r   r#   r$   r   r   r   r   r   Úisave_asT   s   	
ÿ
r*   c                  K   s<   t di | ¤Ž\}}tjdi |¤Ž}t|ƒ}tj|fi |¤ŽS )z7
    Save a book from a data source to another one
    Nr   )r!   r   r   r   Ú	save_book©r   r#   r$   r   r   r   r   Úsave_book_asg   s   r-   c                  K   s8   t di | ¤Ž\}}tjdddi|¤Ž}tj|fi |¤Ž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   TNr   )r!   r   r   r+   r,   r   r   r   Úisave_book_asr   s   	r.   c                  K   ó   t di | ¤Ž}| ¡ S )z‘
    Obtain an array from an excel source

    It accepts the same parameters as :meth:`~pyexcel.get_sheet`
    but return an array instead.
    Nr   )r   Úto_array)r   r   r   r   r   Ú	get_array€   ó   r1   c                 K   s   t d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_rowNr   )r   r   ©r3   r   r   r   r   r   Úget_dictŒ   s   r5   c                 K   s   t d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)

    r3   Nr   )r   ÚlistÚ
to_recordsr4   r   r   r   Úget_records¡   s   r8   c                  K   s   t jd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   TNr   )r   r   r   )r   r%   r   r   r   Ú
iget_array¶   s   r9   c           	      k   s’   � t jdddi|¤Ž}d}t|jƒD ]4\}}|dkr|}q| r;tt||tjd�ƒ}tƒ }| D ]}|| ||< q.|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   )Ú	fillvaluer   )	r   r   Ú	enumerater   Údictr   r	   Ú
DEFAULT_NAr   )	Úcustom_headersr   r%   ÚheadersÚ	row_indexÚrowÚtmp_dictÚordered_dictr   r   r   r   Úiget_recordsÂ   s$   €
ÿÿñrD   c                  K   r/   )z�
    Obtain a dictionary of two dimensional arrays

    It accepts the same parameters as :meth:`~pyexcel.get_book`
    but return a dictionary instead.
    Nr   )r   r   )r   r   r   r   r   Úget_book_dictâ   r2   rE   c                 C   s   t  | ¡}|du rd}|S )z5
    Return the io stream types, string or bytes
    NÚstring)ÚmanagerÚget_io_type)Ú	file_typeÚio_typer   r   r   rH   î   s   
rH   c                  K   sN   i }i }|   ¡ D ]\}}t t|¡}|r| d¡}|||< q|||< q||fS )Né   )ÚitemsÚreÚmatchÚSTARTS_WITH_DESTÚgroup)r   r#   r$   ÚkeyÚvalueÚresultÚ	parameterr   r   r   r!   ø   s   


r!   )r   )N)4Ú__doc__rM   Úpyexcel.constantsr	   Úpyexcel.docstringsÚ
docstringsÚdocsÚpyexcel_io.managerrG   Úpyexcel.internal.coreÚinternalÚcorer   Úpyexcel.bookr   r   Úpyexcel.sheetr   Úpyexcel._compactr   r   r   rO   r)   Ú	GET_SHEETr   ÚGET_BOOKr   Ú	IGET_BOOKr   ÚSAVE_ASr'   ÚISAVE_ASr*   ÚSAVE_BOOK_ASr-   ÚISAVE_BOOK_ASr.   Ú	GET_ARRAYr1   ÚGET_DICTr5   ÚGET_RECORDSr8   Ú
IGET_ARRAYr9   ÚIGET_RECORDSrD   ÚGET_BOOK_DICTrE   rH   r!   r   r   r   r   Ú<module>   sP    	ÿ








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