
    Hf                     Z    d Z ddlmZ ddlmZ  G d de          Z G d de          ZdS )	z
    pyexcel.internal.generators
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Defintion for the sheet and book generators.

    :copyright: (c) 2015-2022 by Onni Software Ltd.
    :license: New BSD License
    )OrderedDictSheetIteratorc                   :    e Zd ZdZd Zd Zed             Zd ZdS )SheetStreama  
    Memory efficient sheet representation

    This class wraps around the data read from pyexcel-io.
    Comparing with :class:`pyexcel.Sheet`, the instance of
    this class does not load all data into memory. Hence
    it performs better when dealing with big data.

    If you would like to do custom rendering for each row
    of the two dimensional data, you would need to
    pass a row formatting/rendering function to the parameter
    "renderer" of pyexcel's signature functions.

    c                 0    || _         || _        g | _        d S N)namepayloadcolnames)selfr
   r   s      ]/var/www/ffwdstore.be/apps/py-env/lib/python3.11/site-packages/pyexcel/internal/generators.py__init__zSheetStream.__init__   s    	    c                     | j         S )z-
        Simply return the generator
        r   r   s    r   to_arrayzSheetStream.to_array#   s     |r   c                 *    t          | j                  S )zarray attribute)listr   r   s    r   arrayzSheetStream.array)   s     DL!!!r   c                     | j         S r	   r   r   s    r   get_internal_arrayzSheetStream.get_internal_array.   s
    |r   N)	__name__
__module____qualname____doc__r   r   propertyr   r    r   r   r   r      sf           
   " " X"    r   r   c                   >    e Zd ZdZddZd Zd Zd Zd Zd	 Z	d
 Z
dS )
BookStreama*  
    Memory efficient book representation

    Comparing with :class:`pyexcel.Book`, the instace of
    this class uses :class:`pyexcel.generators.SheetStream` as
    its internal repesentation of sheet objects. Because `SheetStream`
    does not read data into memory, it is memory efficient.
    Nmemoryc                 p    || _         || _        g | _        |r|                     |           dS i | _        dS )aG  Book constructor

        Selecting a specific book according to filename extension
        :param OrderedDict/dict sheets: a dictionary of data
        :param str filename: the physical file
        :param str path: the relative path or absolute path
        :param set keywords: additional parameters to be passed on
        N)pathfilename
name_arrayload_from_sheetssheets)r   r(   r%   r$   s       r   r   zBookStream.__init__<   sF     	  	!!&)))))DKKKr   c                 |   |dS t                      | _        |                                }t          |t                     st	          |          }|D ]>}t          |||                   }| j                            ||i           || j        |<   ?t          | j                                                  | _	        dS )zLoad content from existing sheets

        :param dict sheets: a dictionary of sheets. Each sheet is
        a list of lists
        N)
r   r(   keys
isinstancesortedr   update__dict__r   r&   )r   r(   r*   r
   sheets        r   r'   zBookStream.load_from_sheetsM   s     >F!mm{{}}&+.. 	  $<<D 	( 	(DfTl33EKe}---"'DM$t{//1122r   c                     | j         S r	   )r&   r   s    r   sheet_nameszBookStream.sheet_namesc   s
    r   c                 n    t                      }| D ]#}|                    |j        |j        i           $|S )z9
        Get book data structure as a dictionary
        )r   r-   r
   r   )r   the_dictr/   s      r   to_dictzBookStream.to_dictf   s?     == 	9 	9EOOUZ78888r   c                      t          |           S r	   r   r   s    r   __iter__zBookStream.__iter__o   s    T"""r   c                 *    t          | j                  S )zReturn the number of sheets)lenr&   r   s    r   number_of_sheetszBookStream.number_of_sheetsr   s    4?###r   c                     t          |t                    r4|t          | j                  k     r| j        |         }| j        |         S d S |}| j        |         S r	   )r+   intr8   r&   r(   )r   index
sheet_names      r   __getitem__zBookStream.__getitem__v   s^    eS!! 	+s4?++++!_U3
{:.. ,+ J;z**r   )Nr"   N)r   r   r   r   r   r'   r1   r4   r6   r9   r>   r   r   r   r!   r!   2   s            "3 3 3,    # # #$ $ $+ + + + +r   r!   N)r   pyexcel._compactr   pyexcel.internal.commonr   objectr   r!   r   r   r   <module>rB      s     ) ( ( ( ( ( 1 1 1 1 1 1! ! ! ! !& ! ! !HK+ K+ K+ K+ K+ K+ K+ K+ K+ K+r   