o
    Û­j°  ã                   @  s¤   d Z ddlmZ ddlmZ ddlmZ ddlZddlm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZmZ er@ddlmZ de	jfddd„Z	dddd„ZdS )z io on the clipboard é    )Úannotations)ÚStringIO)ÚTYPE_CHECKINGN)Úlib)Úfind_stack_level)Úcheck_dtype_backend)ÚABCDataFrame)Ú
get_optionÚoption_context)ÚDtypeBackendú\s+ÚsepÚstrÚdtype_backendúDtypeBackend | lib.NoDefaultc           
      K  sš  |  dd¡}|dur| ¡  dd¡dkrtdƒ‚t|ƒ dd	lm} dd
lm} |ƒ }z| 	| 
d¡p6tdƒ¡}W n	 tyB   Y nw |dd…  d¡dd… dd… }dd„ |D ƒ}t|ƒdkrŒt|ƒdkrŒ|  ¡ dkrŒd} t|d ƒt|d  d¡ƒ }	|	dkrŒ| dtt|	ƒƒ¡ | du r™| 
d¡du r™d} t| ƒdkr«| 
d¡du r«d|d< nt| ƒdkrÀ| 
d¡dkrÀtjdtƒ d� |t|ƒf| |dœ|¤ŽS )až  
    Read text from clipboard and pass to :func:`~pandas.read_csv`.

    Parses clipboard contents similar to how CSV files are parsed
    using :func:`~pandas.read_csv`.

    Parameters
    ----------
    sep : str, default '\\s+'
        A string or regex delimiter. The default of ``'\\s+'`` denotes
        one or more whitespace characters.

    dtype_backend : {'numpy_nullable', 'pyarrow'}, default 'numpy_nullable'
        Back-end data type applied to the resultant :class:`DataFrame`
        (still experimental). Behaviour is as follows:

        * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`
          (default).
        * ``"pyarrow"``: returns pyarrow-backed nullable :class:`ArrowDtype`
          DataFrame.

        .. versionadded:: 2.0

    **kwargs
        See :func:`~pandas.read_csv` for the full argument list.

    Returns
    -------
    DataFrame
        A parsed :class:`~pandas.DataFrame` object.

    See Also
    --------
    DataFrame.to_clipboard : Copy object to the system clipboard.
    read_csv : Read a comma-separated values (csv) file into DataFrame.
    read_fwf : Read a table of fixed-width formatted lines into DataFrame.

    Examples
    --------
    >>> df = pd.DataFrame([[1, 2, 3], [4, 5, 6]], columns=['A', 'B', 'C'])
    >>> df.to_clipboard()  # doctest: +SKIP
    >>> pd.read_clipboard()  # doctest: +SKIP
         A  B  C
    0    1  2  3
    1    4  5  6
    Úencodingúutf-8Nú-Ú Úutf8z3reading from clipboard only supports utf-8 encodingr   )Úclipboard_get)Úread_csvzdisplay.encodingi'  Ú
éÿÿÿÿé
   c                 S  s   h | ]
}|  d ¡ d¡’qS )ú ú	)ÚlstripÚcount)Ú.0Úx© r!   úQ/var/www/html/CropPilot/venv/lib/python3.10/site-packages/pandas/io/clipboards.pyÚ	<setcomp>j   s    z!read_clipboard.<locals>.<setcomp>é   r   z 	Ú	index_colÚdelim_whitespacer   ÚengineÚpythonÚczIread_clipboard with regex separator does not work properly with c engine.©Ú
stacklevel)r   r   )ÚpopÚlowerÚreplaceÚNotImplementedErrorr   Úpandas.io.clipboardr   Úpandas.io.parsersr   ÚdecodeÚgetr	   ÚAttributeErrorÚsplitÚlenr   Ú
setdefaultÚlistÚrangeÚwarningsÚwarnr   r   )
r   r   Úkwargsr   r   r   ÚtextÚlinesÚcountsÚindex_lengthr!   r!   r"   Úread_clipboard   s:   3ÿ"$
þrA   TÚexcelúbool | Noneú
str | NoneÚreturnÚNonec           	      K  s"  |  dd¡}|dur| ¡  dd¡dkrtdƒ‚dd	lm} |du r$d
}|rXz |du r-d}tƒ }| j|f|ddœ|¤Ž | ¡ }||ƒ W dS  t	yW   t
jdtƒ d� Y nw |durdt
jdtƒ d� t| tƒr‡tddƒ� | jdi |¤Ž}W d  ƒ n1 s�w   Y  nt| ƒ}||ƒ dS )a®  
    Attempt to write text representation of object to the system clipboard
    The clipboard can be then pasted into Excel for example.

    Parameters
    ----------
    obj : the object to write to the clipboard
    excel : bool, defaults to True
            if True, use the provided separator, writing in a csv
            format for allowing easy pasting into excel.
            if False, write a string representation of the object
            to the clipboard
    sep : optional, defaults to tab
    other keywords are passed to to_csv

    Notes
    -----
    Requirements for your platform
      - Linux: xclip, or xsel (with PyQt4 modules)
      - Windows:
      - OS X:
    r   r   Nr   r   r   z&clipboard only supports utf-8 encodingr   )Úclipboard_setTr   )r   r   zAto_clipboard in excel mode requires a single character separator.r*   z7to_clipboard with excel=False ignores the sep argument.zdisplay.max_colwidthr!   )r,   r-   r.   Ú
ValueErrorr0   rG   r   Úto_csvÚgetvalueÚ	TypeErrorr:   r;   r   Ú
isinstancer   r
   Ú	to_stringr   )	ÚobjrB   r   r<   r   rG   Úbufr=   Úobjstrr!   r!   r"   Úto_clipboard„   sB   
þÿþ
ÿ€rQ   )r   r   r   r   )TN)rB   rC   r   rD   rE   rF   )Ú__doc__Ú
__future__r   Úior   Útypingr   r:   Úpandas._libsr   Úpandas.util._exceptionsr   Úpandas.util._validatorsr   Úpandas.core.dtypes.genericr   Úpandasr	   r
   Úpandas._typingr   Ú
no_defaultrA   rQ   r!   r!   r!   r"   Ú<module>   s"    þnÿ