o
    h                     @  sZ  U d dl mZ d dlmZmZmZmZ d dlmZm	Z	m
Z
mZmZmZ d dlmZ d dlmZmZ erHd dlmZ ee Zede
egef dZi Zd	ed
< dKddZdLdMddZdNddZdOddZdPd!d"ZedQd%d&Z edRd(d&Z edSd)d&Z edTd*d&Z dUd-d&Z edVd1d2Z!edWd4d2Z!dXd7d2Z!dYd=d>Z"dZdBdCZ#d[dHdIZ$dJS )\    )annotations)HashableIterableMutableMappingSequence)TYPE_CHECKINGAnyCallableLiteralTypeVaroverloadimport_optional_dependency)
is_integeris_list_like)ExcelWriterusecols_func)boundz"MutableMapping[str, ExcelWriter_t]_writersklassExcelWriter_treturnNonec                 C  s"   t | std| j}| t|< dS )z
    Add engine to the excel writer registry.io.excel.

    You must use this method to integrate with ``to_excel``.

    Parameters
    ----------
    klass : ExcelWriter
    z&Can only register callables as enginesN)callable
ValueError_enginer   )r   engine_name r   i/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/pandas/io/excel/_util.pyregister_writer"   s   
r   readerextstrmodeLiteral['reader', 'writer']c                 C  sZ   dddddd}ddddd}|dv sJ |dkr)t d	d
d}|r%d	|d< ||  S ||  S )a  
    Return the default reader/writer for the given extension.

    Parameters
    ----------
    ext : str
        The excel file extension for which to get the default engine.
    mode : str {'reader', 'writer'}
        Whether to get the default engine for reading or writing.
        Either 'reader' or 'writer'

    Returns
    -------
    str
        The default engine for the extension.
    openpyxlpyxlsbxlrdodf)xlsxxlsmxlsbxlsods)r)   r*   r+   r-   )r    writerr.   
xlsxwriterwarn)errorsr)   r   )r!   r#   _default_readers_default_writersr/   r   r   r   get_default_engine2   s$   r4   r   c              
   C  s6   zt |  W S  ty } z	td|  d|d }~ww )NzNo Excel writer '')r   KeyErrorr   )r   errr   r   r   
get_writer[   s   
r8   xintc                 C  sd   d}|    D ]%}t|}|tdk s|tdkr!td|  |d | td d }q|d S )ai  
    Convert Excel column name like 'AB' to 0-based column index.

    Parameters
    ----------
    x : str
        The Excel column name to convert to a 0-based column index.

    Returns
    -------
    num : int
        The column index corresponding to the name.

    Raises
    ------
    ValueError
        Part of the Excel column name was invalid.
    r   AZzInvalid column name:       )upperstripordr   )r9   indexccpr   r   r   
_excel2numb   s   rE   areas	list[int]c                 C  s^   g }|  dD ]%}d|v r%| d}|tt|d t|d d  q|t| q|S )a  
    Convert comma separated list of column names and ranges to indices.

    Parameters
    ----------
    areas : str
        A string containing a sequence of column ranges (or areas).

    Returns
    -------
    cols : list
        A list of 0-based column indices.

    Examples
    --------
    >>> _range2cols('A:E')
    [0, 1, 2, 3, 4]
    >>> _range2cols('A,C,Z:AB')
    [0, 2, 25, 26, 27]
    ,:r   r>   )splitextendrangerE   append)rF   colsrngrngsr   r   r   _range2cols   s   
&rQ   usecolsstr | list[int]c                 C     d S Nr   rR   r   r   r   maybe_convert_usecols      rW   	list[str]c                 C  rT   rU   r   rV   r   r   r   rW      rX   c                 C  rT   rU   r   rV   r   r   r   rW      rX   c                 C  rT   rU   r   rV   r   r   r   rW      rX   1str | list[int] | list[str] | usecols_func | None+None | list[int] | list[str] | usecols_funcc                 C  s2   | du r| S t | rtdt| trt| S | S )a  
    Convert `usecols` into a compatible format for parsing in `parsers.py`.

    Parameters
    ----------
    usecols : object
        The use-columns object to potentially convert.

    Returns
    -------
    converted : object
        The compatible format of `usecols`.
    Nz}Passing an integer for `usecols` is no longer supported.  Please pass in a list of int from 0 to `usecols` inclusive instead.)r   r   
isinstancer"   rQ   rV   r   r   r   rW      s   
freeze_panestuple[int, int]Literal[True]c                 C  rT   rU   r   r]   r   r   r   validate_freeze_panes   rX   ra   Literal[False]c                 C  rT   rU   r   r`   r   r   r   ra      rX   tuple[int, int] | Noneboolc                 C  s6   | d urt | dkrtdd | D rdS tddS )N   c                 s  s    | ]}t |tV  qd S rU   )r\   r:   ).0itemr   r   r   	<genexpr>   s    

z(validate_freeze_panes.<locals>.<genexpr>TzLfreeze_panes must be of form (row, column) where row and column are integersF)lenallr   r`   r   r   r   ra      s   rowlist[Hashable]control_row
list[bool]!tuple[list[Hashable], list[bool]]c                 C  sf   | d }t dt| D ]#}|| s| | }| | dks!| | du r&|| |< qd||< | | }q| |fS )a  
    Forward fill blank entries in row but only inside the same parent index.

    Used for creating headers in Multiindex.

    Parameters
    ----------
    row : list
        List of items in a single row.
    control_row : list of bool
        Helps to determine if particular column is in same parent index as the
        previous value. Used to stop propagation of empty cells between
        different indexes.

    Returns
    -------
    Returns changed row and control_row
    r   r>    NF)rL   ri   )rk   rm   lastir   r   r   fill_mi_header   s   

rs   	index_colint | Sequence[int]&tuple[Hashable | None, list[Hashable]]c                 C  sp   t |rt|tsJ t|}n	t|trJ |}| | }|dkr#dn|}|| d| dg | |d d  fS )a  
    Pop the header name for MultiIndex parsing.

    Parameters
    ----------
    row : list
        The data row to parse for the header name.
    index_col : int, list
        The index columns for our data. Assumed to be non-null.

    Returns
    -------
    header_name : str
        The extracted header name.
    trimmed_row : list
        The original data row with the header name removed.
    rp   Nr>   )r   r\   r   max)rk   rt   rr   header_namer   r   r   pop_header_name  s   
&ry   engine_kwargsdict[str, Any] | Nonekwargsdictc                 C  s$   | du ri }n|   }|| |S )a  
    Used to combine two sources of kwargs for the backend engine.

    Use of kwargs is deprecated, this function is solely for use in 1.3 and should
    be removed in 1.4/2.0. Also _base.ExcelWriter.__new__ ensures either engine_kwargs
    or kwargs must be None or empty respectively.

    Parameters
    ----------
    engine_kwargs: dict
        kwargs to be passed through to the engine.
    kwargs: dict
        kwargs to be psased through to the engine (deprecated)

    Returns
    -------
    engine_kwargs combined with kwargs
    N)copyupdate)rz   r|   resultr   r   r   combine_kwargs6  s
   
r   N)r   r   r   r   )r    )r!   r"   r#   r$   r   r"   )r   r"   r   r   )r9   r"   r   r:   )rF   r"   r   rG   )rR   rS   r   rG   )rR   rY   r   rY   )rR   r   r   r   )rR   r   r   r   )rR   rZ   r   r[   )r]   r^   r   r_   )r]   r   r   rb   )r]   rc   r   rd   )rk   rl   rm   rn   r   ro   )rk   rl   rt   ru   r   rv   )rz   r{   r|   r}   r   r}   )%
__future__r   collections.abcr   r   r   r   typingr   r   r	   r
   r   r   pandas.compat._optionalr   pandas.core.dtypes.commonr   r   pandas.io.excel._baser   typer   objectr   r   __annotations__r   r4   r8   rE   rQ   rW   ra   rs   ry   r   r   r   r   r   <module>   s@     	

)

 !



#"