
    \
qi                        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 ddlmZmZ erddlmZ  ed          de	j        fdd            Z	 dddZdS )zio on the clipboard    )annotations)StringIO)TYPE_CHECKINGN)lib)
set_module)find_stack_level)check_dtype_backend)ABCDataFrame)
get_optionoption_context)DtypeBackendpandasz\s+sepstrdtype_backendDtypeBackend | lib.NoDefaultc                   |                     dd          }|;|                                                    dd          dk    rt          d          t	          |           dd	lm} dd
lm}  |            }	 |	                    |
                    d          pt          d                    }n# t          $ r Y nw xY w|dd                             d          dd         dd         }d |D             }t          |          dk    rt          |          dk    r|                                 dk    rwd} t          |d                   t          |d                             d                    z
  }	|	dk    r0|                    dt#          t%          |	                               n(t'          | t(                    st+          d| d          t          |           dk    r|
                    d          d|d<   nNt          |           dk    r;|
                    d          dk    r"t-          j        dt1                                  |t3          |          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'}
        Back-end data type applied to the resultant :class:`DataFrame`
        (still experimental). If not specified, the default behavior
        is to not use nullable data types. If specified, the behavior
        is as follows:

        * ``"numpy_nullable"``: returns nullable-dtype-backed :class:`DataFrame`
        * ``"pyarrow"``: returns pyarrow-backed nullable
          :class:`ArrowDtype` :class:`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                ^    h | ]*}|                     d                               d          +S ) 	)lstripcount).0xs     t/var/www/html/bestrading.cuttalo.com/services/ml-inference/venv/lib/python3.11/site-packages/pandas/io/clipboards.py	<setcomp>z!read_clipboard.<locals>.<setcomp>n   s0    777Aahhsmm!!$''777       r    z 		index_colzsep=z must be a string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
isinstancer   
ValueErrorwarningswarnr   r   )
r   r   kwargsr   r   r   textlinescountsindex_lengths
             r%   read_clipboardrF      s   j zz*g..H  0 0 8 8b A AV K K!"WXXX&&&111111******=??D{{6::j11SZ@R5S5STT    %Lt$$SbS)#2#.E 87777F
5zzA~~#f++**vzz||q/@/@ 58}}s58??5+A+A'B'BB1k4l0C0C+D+DEEES!! 53C333444 3xx!||

8,,4#x	SA&**X..#55W'))	
 	
 	
 	

 8HTNNS=SSFSSSs   :7B2 2
B?>B?Texcelbool | None
str | NonereturnNonec                   |                     dd          }|;|                                                    dd          dk    rt          d          dd	lm} |d
}|rw	 |d}t                      } | j        |f|dd| |                                } ||           dS # t          $ r% t          j        dt                                 Y n(w xY w|"t          j        dt                                 t          | t                    r6t          dd          5   | j        di |}ddd           n# 1 swxY 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_colwidth )r/   r0   r1   r>   r3   rM   r   to_csvgetvalue	TypeErrorr?   r@   r   r=   r
   r   	to_stringr   )	objrG   r   rA   r   rM   bufrB   objstrs	            r%   to_clipboardrV      s   2 zz*g..H  0 0 8 8b A AV K KABBB111111} 
	{**C CJs@g@@@@@<<>>DM$F 	 	 	MS+--     	
 
E'))	
 	
 	
 	

 #|$$ 2D99 	- 	-"S],,V,,F	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- 	- SM&s%   !AB% %,CC D::D>D>)r   r   r   r   )TN)rG   rH   r   rI   rJ   rK   )__doc__
__future__r   ior   typingr   r?   pandas._libsr   pandas.util._decoratorsr   pandas.util._exceptionsr   pandas.util._validatorsr	   pandas.core.dtypes.genericr
   r   r   r   pandas._typingr   
no_defaultrF   rV   rN   r'   r%   <module>rb      sZ     " " " " " "                          . . . . . . 4 4 4 4 4 4 7 7 7 7 7 7 3 3 3 3 3 3       
  ,++++++ H25.jT jT jT jT jT\ 7;A A A A A A Ar'   