o
    q¨Êh[  ã                	   @   s0  d dl Z d dlZd dlZd dlZddlmZ ddlmZmZm	Z	m
Z
mZmZmZmZmZmZ ddlmZmZ ddlT 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 ej  !d¡rbd dl"Z"zd dl#Z#dZ$W n e%yu   d Z$Y nw e$Z&dej'd e&dddddf	dd„Z(ej'dfdd„Z)ej'fdd„Z*dS )é    Né   )Útimemachine)
ÚXL_CELL_BLANKÚXL_CELL_BOOLEANÚXL_CELL_DATEÚXL_CELL_EMPTYÚXL_CELL_ERRORÚXL_CELL_NUMBERÚXL_CELL_TEXTÚ	XLRDErrorÚbiff_text_from_numÚerror_text_from_code)ÚBookÚcolname)Ú*)Ú__VERSION__Ú__version__)Ú
empty_cell)ÚXLDateErrorÚxldate_as_datetimeÚxldate_as_tuple)ÚX12BookÚ
IronPythonFc	                 C   s4  d}	|r|d|	… }
n t j | ¡} t| dƒ�}| |	¡}
W d  ƒ n1 s&w   Y  |
dkr„|r:t t |¡¡}nt | ¡}t	dd„ | 
¡ D ƒƒ}|rW| d¡ t ||¡ d|v rpd	d
lm} |j||||||||d�}|S d|v rxtdƒ‚d|v r€tdƒ‚tdƒ‚d	dlm} |j| ||||||||d�	}|S )aÉ  
    Open a spreadsheet file for data extraction.

    :param filename: The path to the spreadsheet file to be opened.

    :param logfile: An open file to which messages and diagnostics are written.

    :param verbosity: Increases the volume of trace material written to the
                      logfile.

    :param use_mmap:

      Whether to use the mmap module is determined heuristically.
      Use this arg to override the result.

      Current heuristic: mmap is used if it exists.

    :param file_contents:

      A string or an :class:`mmap.mmap` object or some other behave-alike
      object. If ``file_contents`` is supplied, ``filename`` will not be used,
      except (possibly) in messages.

    :param encoding_override:

      Used to overcome missing or bad codepage information
      in older-version files. See :doc:`unicode`.

    :param formatting_info:

      The default is ``False``, which saves memory.
      In this case, "Blank" cells, which are those with their own formatting
      information but no data, are treated as empty by ignoring the file's
      ``BLANK`` and ``MULBLANK`` records.
      This cuts off any bottom or right "margin" of rows of empty or blank
      cells.
      Only :meth:`~xlrd.sheet.Sheet.cell_value` and
      :meth:`~xlrd.sheet.Sheet.cell_type` are available.

      When ``True``, formatting information will be read from the spreadsheet
      file. This provides all cells, including empty and blank cells.
      Formatting information is available for each cell.

      Note that this will raise a NotImplementedError when used with an
      xlsx file.

    :param on_demand:

      Governs whether sheets are all loaded initially or when demanded
      by the caller. See :doc:`on_demand`.

    :param ragged_rows:

      The default of ``False`` means all rows are padded out with empty cells so
      that all rows have the same size as found in
      :attr:`~xlrd.sheet.Sheet.ncols`.

      ``True`` means that there are no empty cells at the ends of rows.
      This can result in substantial memory savings if rows are of widely
      varying sizes. See also the :meth:`~xlrd.sheet.Sheet.row_len` method.

    :returns: An instance of the :class:`~xlrd.book.Book` class.
    é   NÚrbs   PKc                 S   s   g | ]	}t  |¡|f‘qS © )r   Úconvert_filename)Ú.0Únamer   r   ú?/var/www/html/env/lib/python3.10/site-packages/xlrd/__init__.pyÚ
<listcomp>z   s    ÿz!open_workbook.<locals>.<listcomp>zZIP component_names:
zxl/workbook.xmlr   )Úxlsx)ÚlogfileÚ	verbosityÚuse_mmapÚformatting_infoÚ	on_demandÚragged_rowszxl/workbook.binz#Excel 2007 xlsb file; not supportedzcontent.xmlz&Openoffice.org ODS file; not supportedz.ZIP file contents not a known type of workbook)Úbook)	Úfilenamer"   r#   r$   Úfile_contentsÚencoding_overrider%   r&   r'   )ÚosÚpathÚ
expanduserÚopenÚreadÚzipfileÚZipFiler   ÚBYTES_IOÚdictÚnamelistÚwriteÚpprintÚ r!   Úopen_workbook_2007_xmlr   r(   Úopen_workbook_xls)r)   r"   r#   r$   r*   r+   r%   r&   r'   ÚpeekszÚpeekÚfÚzfÚcomponent_namesr!   Úbkr(   r   r   r   Úopen_workbook!   s`   Iÿ
ÿ
ø
÷rA   c                 C   s<   ddl m} tƒ }|j| |d� ||j|j|jd||ƒ dS )a  
    For debugging: dump an XLS file's BIFF records in char & hex.

    :param filename: The path to the file to be dumped.
    :param outfile: An open file, to which the dump is written.
    :param unnumbered: If true, omit offsets (for meaningful diffs).
    r   )Ú	biff_dump©r)   r"   r   N)ÚbiffhrB   r   Úbiff2_8_loadÚmemÚbaseÚ
stream_len)r)   ÚoutfileÚ
unnumberedrB   r@   r   r   r   Údump¢   s   rK   c                 C   s8   ddl m} tƒ }|j| |d� ||j|j|j|ƒ dS )a  
    For debugging and analysis: summarise the file's BIFF records.
    ie: produce a sorted file of ``(record_name, count)``.

    :param filename: The path to the file to be summarised.
    :param outfile: An open file, to which the summary is written.
    r   )Úbiff_count_recordsrC   N)rD   rL   r   rE   rF   rG   rH   )r)   rI   rL   r@   r   r   r   Úcount_records°   s   rM   )+r,   r7   Úsysr1   r8   r   rD   r   r   r   r   r   r	   r
   r   r   r   r(   r   r   ÚformulaÚinfor   r   Úsheetr   Úxldater   r   r   r!   r   ÚversionÚ
startswithÚ	encodingsÚmmapÚMMAP_AVAILABLEÚImportErrorÚUSE_MMAPÚstdoutrA   rK   rM   r   r   r   r   Ú<module>   sD   0ÿ
ø 