U
    ®[Öe´  ã                   @   sX   d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd„ de	ƒZ
G dd	„ d	e	ƒZdS )
zÈ
    pyexcel_io.sheet
    ~~~~~~~~~~~~~~~~~~~

    The io interface to file extensions

    :copyright: (c) 2014-2022 by Onni Software Ltd.
    :license: New BSD License, see LICENSE for more details
é    N)Ú_index_filter)Úirange)ÚNamedContentc                	   @   sR   e Zd ZdZddd„Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
dd„ ZdS )ÚSheetReaderz
    Generic sheet reader
    r   éÿÿÿÿNFc                 K   sf   || _ i | _| j |¡ || _|| _|| _|| _t| _t| _	|| _
|	| _|
| _|rX|| _|rb|| _	d S ©N)Ú_native_sheetÚ	_keywordsÚupdateÚ
_start_rowÚ
_row_limitÚ_start_columnÚ_column_limitr   Ú	_skip_rowÚ_skip_columnÚ_skip_empty_rowsÚ_row_rendererÚkeep_trailing_empty_cells)ÚselfZsheetZ	start_rowZ	row_limitZstart_columnZcolumn_limitZskip_row_funcZskip_column_funcZskip_empty_rowsZrow_rendererr   Zdeprecated_use_of_keywords_here© r   úR/var/www/html/services/stratfitenv/lib/python3.8/site-packages/pyexcel_io/sheet.pyÚ__init__   s     zSheetReader.__init__c           	      c   sø   t |  ¡ ƒD ]æ\}}|  || j| j¡}|tjkr4qn|tjkrB qôg }g }t |  |¡ƒD ]n\}}|  	|| j
| j¡}|tjkr€qXn|tjkrŽ qÈ| jr | |¡ qX| |¡ |dk	rX|dkrX||7 }g }qX| jrÜt|ƒdk rÜq| jrì|  |¡}|V  qdS )z+2 dimentional representation of the contentNÚ é   )Ú	enumerateÚrow_iteratorr   r   r   Ú	constantsZ	SKIP_DATAZSTOP_ITERATIONÚcolumn_iteratorr   r   r   r   Úappendr   Úlenr   )	r   Z	row_indexÚrowZrow_positionZ
return_rowZtmp_rowÚcolumn_indexÚ
cell_valueZcolumn_positionr   r   r   Úto_array5   sF      ÿ

ÿ  ÿ



zSheetReader.to_arrayc                 C   s   t |  ¡ ƒS )z•
        iterate each row

        override this function in the sitation where
        number_of_rows() is difficult or costly to implement
        )r   Únumber_of_rows©r   r   r   r   r   `   s    zSheetReader.row_iteratorc                 c   s$   t |  ¡ ƒD ]}|  ||¡V  qdS )zª
        iterate each column of a given row

        override this function in the sitation where
        number_of_columns() is difficult or costly to implement
        N)r   Únumber_of_columnsr"   ©r   r    Úcolumnr   r   r   r   i   s    zSheetReader.column_iteratorc                 C   s   t dƒ‚dS )ú:
        implement this method for easy extension
        z!Please implement number_of_rows()N©Ú	Exceptionr%   r   r   r   r$   s   s    zSheetReader.number_of_rowsc                 C   s   t dƒ‚dS )r)   z$Please implement number_of_columns()Nr*   r%   r   r   r   r&   y   s    zSheetReader.number_of_columnsc                 C   s   t dƒ‚dS )r)   zPlease implement cell_value()Nr*   r'   r   r   r   r"      s    zSheetReader.cell_valuec                 C   s   d S r   r   r%   r   r   r   Úclose…   s    zSheetReader.close)	r   r   r   r   NNFNF)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r#   r   r   r$   r&   r"   r,   r   r   r   r   r      s$            õ
 +	
r   c                   @   s8   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ ZdS )ÚSheetWriterz
    Generic sheet writer
    c                 K   s0   |r
|}nt j}|| _|| _|| _|  |¡ d S r   )r   ZDEFAULT_SHEET_NAMEZ_native_bookr   r	   Úset_sheet_name)r   Znative_bookZnative_sheetÚnameÚkeywordsZ
sheet_namer   r   r   r   Ž   s    zSheetWriter.__init__c                 C   s   dS )z 
        Set sheet name
        Nr   )r   r3   r   r   r   r2   ˜   s    zSheetWriter.set_sheet_namec                 C   s   t dƒ‚dS )z+
        write a row into the file
        zPlease implement write_row()N)ÚNotImplementedError)r   Úarrayr   r   r   Ú	write_rowž   s    zSheetWriter.write_rowc                 C   s   |D ]}|   |¡ qdS )z6
        For standalone usage, write an array
        N)r7   )r   Útabler    r   r   r   Úwrite_array¤   s    zSheetWriter.write_arrayc                 C   s   dS )z2
        This call actually save the file
        Nr   r%   r   r   r   r,   «   s    zSheetWriter.closeN)	r-   r.   r/   r0   r   r2   r7   r9   r,   r   r   r   r   r1   ‰   s   
r1   )r0   Zpyexcel_io.constantsr   Zpyexcel_io.utilsr   Zpyexcel_io._compactr   Zpyexcel_io.plugin_apir   Úobjectr   r1   r   r   r   r   Ú<module>   s   	y