3
���h2T � @ sj d Z dZddlZddlZddlmZmZmZmZmZ ddl Z ddl
Z
ddlZddlZddl
Z
e jdd�ZdZdZe
j� d kr�d
ZndZdd
� ZG dd� de�ZG dd� de�Zed�dd�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Z d#d$� Z!G d%d&� d&�Z"d'd(� Z#d)d*� Z$d+d,� Z%d-d.� Z&d/d0� Z'd1d2� Z(e)d�d3d4�Z*e'e( a+a,d5d6d.d,gZ-t,Z.t+Z/dS )7ae
Pyperclip
A cross-platform clipboard module for Python,
with copy & paste functions for plain text.
By Al Sweigart al@inventwithpython.com
BSD License
Usage:
import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')
spam = pyperclip.paste()
if not pyperclip.is_available():
print("Copy functionality unavailable!")
On Windows, no additional modules are needed.
On Mac, the pyobjc module is used, falling back to the pbcopy and pbpaste cli
commands. (These commands should come with OS X.).
On Linux, install xclip or xsel via package manager. For example, in Debian:
sudo apt-get install xclip
sudo apt-get install xsel
Otherwise on Linux, you will need the PyQt5 modules installed.
This module does not work with PyGObject yet.
Cygwin is currently not supported.
Security Note: This module runs programs with these names:
- which
- where
- pbcopy
- pbpaste
- xclip
- xsel
- klipper
- qdbus
A malicious user could rename or add programs with these names, tricking
Pyperclip into running them with whatever permissions the Python process has.
z1.7.0� N)�c_size_t�c_wchar� c_wchar_p� get_errno�sizeofZDISPLAYFz�
Pyperclip could not find a copy/paste mechanism for your system.
For more information, please visit
https://pyperclip.readthedocs.io/en/latest/introduction.html#not-implemented-error
zutf-8�Windows�where�whichc C s t jt| gt jt jd�dkS )N)�stdout�stderrr )�
subprocess�call� WHICH_CMD�PIPE)�name� r �>/tmp/pip-build-5_djhm0z/pandas/pandas/io/clipboard/__init__.py�_executable_existsJ s r c @ s e Zd ZdS )�PyperclipExceptionN)�__name__�
__module__�__qualname__r r r r r T s r c s e Zd Z� fdd�Z� ZS )�PyperclipWindowsExceptionc s$ |dt j� � d�7 }t� j|� d S )Nz (�))�ctypesZWinError�super�__init__)�self�message)� __class__r r r Y s z"PyperclipWindowsException.__init__)r r r r �
__classcell__r r )r r r X s r )�returnc C s2 t tttf}t| |�s*tdt| �j� ���t | �S )NzJonly str, int, float, and bool values can be copied to the clipboard, not )�str�int�float�bool�
isinstancer �typer )�textZ
acceptedTypesr r r �_stringifyText^ s
r) c C s dd� } dd� }| |fS )Nc S s4 t | �} tjddgtjdd�}|j| jt�d� d S )N�pbcopy�wT)�stdin� close_fds)�input)r) r �Popenr �communicate�encode�ENCODING)r( �pr r r �copy_osx_pbcopyi s z2init_osx_pbcopy_clipboard.<locals>.copy_osx_pbcopyc S s, t jddgt jdd�} | j� \}}|jt�S )NZpbpaste�rT)r
r- )r r/ r r0 �decoder2 )r3 r
r r r r �paste_osx_pbcopyn s z3init_osx_pbcopy_clipboard.<locals>.paste_osx_pbcopyr )r4 r7 r r r �init_osx_pbcopy_clipboardh s r8 c C s dd� } dd� }| |fS )Nc S sP t | �} tjj| �j� }|jtj�}tjj � }|j
tjgd� |j|tj� dS )z!Copy string argument to clipboardN)
r) �
FoundationZNSStringZstringWithString_ZnsstringZdataUsingEncoding_ZNSUTF8StringEncoding�AppKit�NSPasteboard�generalPasteboardZdeclareTypes_owner_�NSStringPboardTypeZsetData_forType_)r( ZnewStrZnewData�boardr r r �copy_osx_pyobjcw s
z2init_osx_pyobjc_clipboard.<locals>.copy_osx_pyobjcc S s t jj� } | jt j�}|S )zReturns contents of clipboard)r: r; r< |