B @`@sLdZddlmZddlZddlmZddlmZmZd ddZ d d d Z dS)z io on the clipboard )StringION) ABCDataFrame) get_optionoption_context\s+cKsZ|dd}|dk r0|dddkr0tddd lm}dd lm}|}y|| dpdt d }Wnt k r~YnX|dd  d dddd}dd|D}t |dkrt |dkr|dkrd}|dkr| ddkrd}t |dkr| ddkrd|d<n(t |dkrB| ddkrBtd|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|]}|dqS) )lstripcount).0xr8/tmp/pip-unpacked-wheel-q9tj5l6a/pandas/io/clipboards.py :sz!read_clipboard..rZdelim_whitespacez\s+ZenginepythonczHread_clipboard with regex separator does not work properly with c enginesep)poplowerreplaceNotImplementedErrorpandas.io.clipboardr Zpandas.io.parsersr decodegetrAttributeErrorsplitlenwarningswarnr)rkwargsrr r textlinescountsrrrread_clipboard s,   "$ r,Tc Ks|dd}|dk r0|dddkr0tddd lm}|dkrHd }|ry>|dkrZd }t}|j|f|dd ||}||dSt k rt d YqXn|dk rt dt |t rtdd|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_csvgetvalue TypeErrorr&r' isinstancerrZ to_stringstr) objexcelrr(rr-bufr)Zobjstrrrr to_clipboardNs2     r6)r)TN) __doc__iorr&Zpandas.core.dtypes.genericrZpandasrrr,r6rrrrs    D