U
    ÎZj5  ã                   @  st   d 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mZ dd	d
œdd„Zdddddœdd„ZdS )z io on the clipboard é    )Úannotations)ÚStringION)Úfind_stack_level)ÚABCDataFrame)Ú
get_optionÚoption_contextú\s+Ústr)Úsepc           	      K  s¦  |  dd¡}|dk	r0| ¡  dd¡dkr0tdƒ‚dd	lm} dd
lm} |ƒ }z| | 	d¡pdt
dƒ¡}W n tk
r~   Y nX |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k�r8| 	d¡dk�r8d} t| ƒdk�r`| 	d¡dk�r`d|d< n.t| ƒdk�rŽ| 	d¡dk�rŽtjdtƒ d� |t|ƒfd| 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.
    Ú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   úW/var/www/html/TRUCKING_PROJECT/venv/lib/python3.8/site-packages/pandas/io/clipboards.pyÚ	<setcomp>A   s     z!read_clipboard.<locals>.<setcomp>é   r   z 	Z	index_colZdelim_whitespacer   ZengineÚpythonÚczIread_clipboard with regex separator does not work properly with c engine.©Ú
stacklevelr
   )ÚpopÚlowerÚreplaceÚNotImplementedErrorÚpandas.io.clipboardr   Zpandas.io.parsersr   ÚdecodeÚgetr   ÚAttributeErrorÚsplitÚlenr   Ú
setdefaultÚlistÚrangeÚwarningsÚwarnr   r   )	r
   Úkwargsr   r   r   ÚtextÚlinesÚcountsZindex_lengthr   r   r   Úread_clipboard   s6    "*

þr6   Tzbool | Nonez
str | NoneÚNone)Úexcelr
   Úreturnc           	   	   K  s  |  dd¡}|dk	r0| ¡  dd¡dkr0tdƒ‚dd	lm} |dkrHd
}|r´z@|dkrZd}tƒ }| j|f|ddœ|—Ž | ¡ }||ƒ W dS  t	k
r°   t
jdtƒ d� Y qÌX n|dk	rÌt
jdtƒ d� t| tƒrútddƒ� | jf |Ž}W 5 Q R X 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#   r$   r%   Ú
ValueErrorr'   r:   r   Zto_csvÚgetvalueÚ	TypeErrorr0   r1   r   Ú
isinstancer   r   Z	to_stringr	   )	Úobjr8   r
   r2   r   r:   Úbufr3   Zobjstrr   r   r   Úto_clipboard[   s<    þþ
rA   )r   )TN)Ú__doc__Ú
__future__r   Úior   r0   Zpandas.util._exceptionsr   Zpandas.core.dtypes.genericr   Zpandasr   r   r6   rA   r   r   r   r   Ú<module>   s   K   ÿ