HOME


sh-3ll 1.0
DIR:/usr/local/lib64/python3.6/site-packages/pandas/io/__pycache__/
Upload File :
Current File : //usr/local/lib64/python3.6/site-packages/pandas/io/__pycache__/clipboards.cpython-36.pyc
3

���h��@sLdZddlmZddlZddlmZddlmZmZddd�Z	d
d
d�Z
dS)z io on the clipboard �)�StringION)�ABCDataFrame)�
get_option�option_context�\s+cKsZ|jdd�}|dk	r0|j�jdd�dkr0td��dd	lm}dd
lm}|�}y|j|j	d�pdt
d��}Wntk
r~YnX|dd�jd
�dd�dd�}dd�|D�}t
|�dkr�t
|�dkr�|j�dkr�d}|dkr�|j	d�dkr�d}t
|�dk�r|j	d�dk�rd|d<n(t
|�dk�rB|j	d�dk�rBtjd�|t|�fd|i|��S)aj
    Read text from clipboard and pass to read_csv.

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

    **kwargs
        See read_csv for the full argument list.

    Returns
    -------
    DataFrame
        A parsed DataFrame object.
    �encodingzutf-8N�-��utf8z3reading from clipboard only supports utf-8 encodingr)�
clipboard_get)�read_csvzdisplay.encodingi'�
��
cSsh|]}|j�jd��qS)�	)�lstrip�count)�.0�x�r�6/tmp/pip-build-5_djhm0z/pandas/pandas/io/clipboards.py�	<setcomp>:sz!read_clipboard.<locals>.<setcomp>rZdelim_whitespacez\s+Zengine�python�czHread_clipboard with regex separator does not work properly with c engine�sep���)�pop�lower�replace�NotImplementedError�pandas.io.clipboardrZpandas.io.parsersr�decode�getr�AttributeError�split�len�warnings�warnr)r�kwargsrrr�text�lines�countsrrr�read_clipboard
s,"$
r,Tc	Ks|jdd�}|dk	r0|j�jdd�dkr0td��dd	lm}|dkrHd
}|r�y>|dkrZd}t�}|j|f|dd�|��|j�}||�dSt	k
r�t
jd
�Yq�Xn|dk	r�t
jd�t|t
�r�tdd��|jf|�}WdQRXnt|�}||�dS)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 : boolean, 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:
    rzutf-8Nrr	r
z&clipboard only supports utf-8 encodingr)�
clipboard_setTr)rrzAto_clipboard in excel mode requires a single character separator.z6to_clipboard with excel=False ignores the sep argumentzdisplay.max_colwidth)rrr�
ValueErrorr r-rZto_csv�getvalue�	TypeErrorr&r'�
isinstancerrZ	to_string�str)	�obj�excelrr(rr-�bufr)Zobjstrrrr�to_clipboardNs2

r6)r)TN)�__doc__�iorr&Zpandas.core.dtypes.genericrZpandasrrr,r6rrrr�<module>s
D