o
    ‹¨Êhÿ
  ã                   @   st   d Z ddlmZ ddlmZmZmZ ddlmZ G dd„ de	ƒZ
G dd„ deƒZG d	d
„ d
eƒZG dd„ deƒZdS )zÝ
    pyexcel.plugins.sources.pydata
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Representation of array, dict, records and book dict sources

    :copyright: (c) 2015-2017 by Onni Software Ltd.
    :license: New BSD License
é    N)ÚPY2ÚOrderedDictÚzip_longest)ÚSheetReaderc                   @   s(   e Zd ZdZdd„ Zdd„ Zdd„ ZdS )	Ú_FakeIOzemulates a stream objectc                 C   s
   d | _ d S ©N©Ú_FakeIO__value©Úself© r   úW/var/www/html/env/lib/python3.10/site-packages/pyexcel/plugins/sources/pydata/common.pyÚ__init__   s   
z_FakeIO.__init__c                 C   s
   || _ dS )zduck method setvalueNr   )r   Úvaluer   r   r   Úsetvalue   s   
z_FakeIO.setvaluec                 C   s   | j S )zduck method getvaluer   r
   r   r   r   Úgetvalue   s   z_FakeIO.getvalueN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r      s
    r   c                   @   s    e Zd ZdZdd„ Zdd„ ZdS )ÚArrayReaderz0read data from an array via pyexcel-io interfacec                 c   s   � | j D ]}|V  qd S r   ©Ú_native_sheet)r   Úrowr   r   r   Úrow_iterator"   s   €
ÿzArrayReader.row_iteratorc                 c   s   � |D ]}|V  qd S r   r   )r   r   Úcellr   r   r   Úcolumn_iterator&   s   €ÿzArrayReader.column_iteratorN)r   r   r   r   r   r   r   r   r   r   r      s    r   c                   @   ó   e Zd ZdZdd„ ZdS )ÚRecordsReaderaÊ  read data from a records via pyexcel-io interface

    By default, all records are assumed to have the keys and
    the keys of the first dictionary of the records will be
    taken as a reference.

    When the keys of the first dictionary is the full list,
    The records reader will fill-in the missing key with
    default n/a, which is ''.

    Otherwise, please supply a complete list of keys as a
    parameter to get_records method, or save_as

    c                 c   sˆ   � | j  d¡}t| jƒD ]5\}}|dkr-|d u r*t|tƒr$t| ¡ ƒ}nt| ¡ ƒ}|V  g }|D ]}| 	| |t
j¡¡ q1|V  qd S )NÚcustom_headersr   )Ú	_keywordsÚgetÚ	enumerater   Ú
isinstancer   ÚlistÚkeysÚsortedÚappendÚ	constantsÚ
DEFAULT_NA)r   ÚheadersÚindexr   ÚvaluesÚkr   r   r   r   <   s   €
ôzRecordsReader.row_iteratorN©r   r   r   r   r   r   r   r   r   r   ,   s    r   c                   @   r   )Ú
DictReaderz4read data from a dictionary via pyexcel-io interfacec                 #   s¢   � ˆ j  ¡ }tst|ƒ}tˆ j tƒst|ƒ}ˆ j dd¡r |V  tˆ j |d  tƒrC‡ fdd„|D ƒ}t	|dt
jiŽD ]}|V  q;d S ‡ fdd„|D ƒ}|V  d S )	NÚ	with_keysTr   c                 3   s   � | ]}ˆ j | V  qd S r   r   ©Ú.0Úkeyr
   r   r   Ú	<genexpr>[   s   € z*DictReader.row_iterator.<locals>.<genexpr>Ú	fillvaluec                    s   g | ]}ˆ j | ‘qS r   r   r1   r
   r   r   Ú
<listcomp>a   s    z+DictReader.row_iterator.<locals>.<listcomp>)r   r%   r   r$   r#   r   r&   r    r!   r   r(   r)   )r   r%   Úsorted_valuesr   r   r
   r   r   Q   s&   €
ÿ
ÿý
zDictReader.row_iteratorNr.   r   r   r   r   r/   N   s    r/   )r   Úpyexcel.constantsr(   Úpyexcel._compactr   r   r   Úpyexcel_io.sheetr   Úobjectr   r   r   r/   r   r   r   r   Ú<module>   s    	"