o
    i                     @  sR  U 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 d dlmZmZ erDd dlmZ ee Zedeegef dZi Zded	< dJddZdKdLddZdMddZdNddZdOd d!ZedPd$d%ZedQd'd%ZedRd(d%ZedSd)d%ZdTd,d%ZedUd0d1Z edVd3d1Z dWd6d1Z dXd<d=Z!dYdAdBZ"dZdGdHZ#dIS )[    )annotations)
TYPE_CHECKINGAnyCallableHashableIterableLiteralMutableMappingSequence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   P/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/pandas/io/excel/_util.pyregister_writer    s   
r   readerextstrmodeLiteral['reader', 'writer']c                 C  s\   d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xlwt)r    writerr/   
xlsxwriterwarn)errorsr)   r   )r!   r#   _default_readers_default_writersr0   r   r   r   get_default_engine0   s&   r5   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_writerZ   s   
r9   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   )r:   indexccpr   r   r   
_excel2numa   s   rF   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rangerF   append)rG   colsrngrngsr   r   r   _range2cols   s   
&rR   usecolsstr | list[int]c                 C     d S Nr   rS   r   r   r   maybe_convert_usecols      rX   	list[str]c                 C  rU   rV   r   rW   r   r   r   rX      rY   c                 C  rU   rV   r   rW   r   r   r   rX      rY   c                 C  rU   rV   r   rW   r   r   r   rX      rY   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"   rR   rW   r   r   r   rX      s   
freeze_panestuple[int, int]Literal[True]c                 C  rU   rV   r   r^   r   r   r   validate_freeze_panes   rY   rb   Literal[False]c                 C  rU   rV   r   ra   r   r   r   rb      rY   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 rV   )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   ra   r   r   r   rb      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)rM   rj   )rl   rn   lastir   r   r   fill_mi_header   s   

rt   	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.
    rq   Nr?   )r   r]   r   max)rl   ru   rs   header_namer   r   r   pop_header_name  s   
&rz   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)r{   r}   resultr   r   r   combine_kwargs5  s
   
r   N)r   r   r   r   )r    )r!   r"   r#   r$   r   r"   )r   r"   r   r   )r:   r"   r   r;   )rG   r"   r   rH   )rS   rT   r   rH   )rS   rZ   r   rZ   )rS   r   r   r   )rS   r   r   r   )rS   r[   r   r\   )r^   r_   r   r`   )r^   r   r   rc   )r^   rd   r   re   )rl   rm   rn   ro   r   rp   )rl   rm   ru   rv   r   rw   )r{   r|   r}   r~   r   r~   )$
__future__r   typingr   r   r   r   r   r   r	   r
   r   r   pandas.compat._optionalr   pandas.core.dtypes.commonr   r   pandas.io.excel._baser   typer   objectr   r   __annotations__r   r5   r9   rF   rR   rX   rb   rt   rz   r   r   r   r   r   <module>   s>    0

*

 !



#"