
    Hf                        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             Z eej                  d             Z eej                  d             Z eej                  d             Z eej                  d             Z eej                   d             Z! eej"                  d             Z# eej$                  d             Z% eej&                  dd            Z' eej(                  dd            Z) eej*                  d             Z+ eej,                  dd            Z- eej.                  d             Z/d Z0d 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                      i }t           j        D ]}|| v r|                     |          ||<   t          j        di | }t          |j        |j        fi |}|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fieldnamed_contentsheets        N/var/www/ffwdstore.be/apps/py-env/lib/python3.11/site-packages/pyexcel/core.py	get_sheetr      su    
 L1 6 6H"*,,u"5"5L,88x88M-');LL|LLEL    c                      t          j        di | }t          |                                |j        |j                  }|S )z?
    Get an instance of :class:`Book` from an excel source
    )filenamepathr   )r   get_book_streamr   to_dictr   r   )r   book_streambooks      r   get_bookr$   *   sP    
 )55H55K%  D
 Kr   c                  (    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_demandTr   )r   r    )r   s    r   	iget_bookr'   8   s      ">>T>X>>>r   c                     t          di | \  }}i }t          j        D ]}||v r|                    |          ||<   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_namer   )
_split_keywordsr   r   r   r   r   r   r   r   
save_sheet)r   dest_keywordssource_keywordsr   r   sheet_streamoutput_sheet_namer   s           r   save_asr0   C   s    
 &5%@%@x%@%@"M?L1 = =O##"1"5"5e"<"<L+>>o>>L$)}$$),7,&(9JJ\JJEe55}555r   c                      t          di | \  }}t          j        D ]}||v rt          t                    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)   r   )	r*   r   r   	ExceptionSAVE_AS_EXCEPTIONr   r   r   r+   )r   r,   r-   r   r   s        r   isave_asr4   U   s     &5%@%@x%@%@"M?1 / /O##-... $$GGtGGGE}$$"<0
e55}555r   c                      t          di | \  }}t          j        di |}t          |          }t          j        |fi |S )z7
    Save a book from a data source to another one
    r   )r*   r   r    r   	save_bookr   r,   r-   r#   s       r   save_book_asr8   h   sV    
 &5%@%@x%@%@"M?"55_55D4==DT33]333r   c                  j    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&   Tr   )r*   r   r    r6   r7   s       r   isave_book_asr:   s   sP     &5%@%@x%@%@"M?"EETE_EEDT33]333r   c                  B    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.
    r   )r   to_array)r   r   s     r   	get_arrayr=      s'     !!!!E>>r   c                 F    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_rowr   )r   r!   r?   r   r   s      r   get_dictrA      s+    " JJ*=JJJE==??r   c                 `    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)

    r?   r   )r   list
to_recordsr@   s      r   get_recordsrE      s7    " JJ*=JJJE  ""###r   c                  6    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&   Tr   )r   r   r   )r   r.   s     r   
iget_arrayrG      s(     +GGdGhGGLr   c              +   l  K   t          j        dddi|}d}t          |j                  D ]\  }}|dk    r|}| rLt	          t          ||t          j                            }t                      }| D ]}||         ||<   |V  \t          t          ||t          j                            V  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   s	            r   iget_recordsrS      s       +GGdGhGGLG#L$899  	3>>GG 	8LMMM   +}}* 8 8D)1$L&&""""" "	8LMMM      r   c                  B    t          di | }|                                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#   s     r   get_book_dictrU      s%     hD<<>>r   c                 6    t          j        |           }|d}|S )z5
    Return the io stream types, string or bytes
    Nstring)r   get_io_type)	file_typeio_types     r   rX   rX      s#     !),,GNr   c                      i }i }|                                  D ]A\  }}t          j        t          |          }|r|                    d          }|||<   <|||<   B||fS )N   )itemsrematchSTARTS_WITH_DESTgroup)r   r,   r-   keyvalueresult	parameters          r   r*   r*      sw    MOnn&& ) )
U*C00 	)QI',M)$$#(OC  /))r   )r   )N)2__doc__r^   pyexcelr   r   docspyexcel.bookr   r   pyexcel.sheetr   pyexcel._compactr   r	   r
   pyexcel.internalr   r   
pyexcel_ior   r`   r3   	GET_SHEETr   GET_BOOKr$   	IGET_BOOKr'   SAVE_ASr0   ISAVE_ASr4   SAVE_BOOK_ASr8   ISAVE_BOOK_ASr:   	GET_ARRAYr=   GET_DICTrA   GET_RECORDSrE   
IGET_ARRAYrG   IGET_RECORDSrS   GET_BOOK_DICTrU   rX   r*   r   r   r   <module>r{      s    
			 * * * * * * & & & & & & & & & & & & & &       A A A A A A A A A A , , , , , , ) ) ) ) ) ) :  DN
 
 
 DM
 
 
 DN? ? ? DL6 6 6" DM6 6 6$ D4 4 4 D
4 
4  
4 DN   DM   ( D$ $ $ $( DO      D   > D     
* 
* 
* 
* 
*r   