U Dx`@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}|}z|| 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. encodingutf-8N-utf8z3reading from clipboard only supports utf-8 encodingr) clipboard_get)read_csvzdisplay.encodingi' cSsh|]}|dqS) )lstripcount).0xr;/tmp/pip-target-zr53vnty/lib/python/pandas/io/clipboards.py :sz!read_clipboard..rZdelim_whitespacerZenginepythonczHread_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 }|rz@|dkrZd }t}|j|f|dd ||}||WdSt k rt d YqXn|dk rt dt |t rtdd|jf|}W5QRXnt|}||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: rrNr r 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_clipboardNs4      r7)r)TN) __doc__iorr'Zpandas.core.dtypes.genericrZpandasrrr-r7rrrrs    D