1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
U
¬ý°d”Wã@spdZdZddlZddlZddlmZmZmZmZmZddl    Z    ddl
Z
ddl m Z ddl Z ddlZddlZddlmZmZddlmZe     d¡Zd    Zd
Ze
 ¡d kr¨d Znd Zdd„Zedœdd„Zdd„Zdd„Zdd„Z dd„Z!dd„Z"dd„Z#dd „Z$d!d"„Z%Gd#d$„d$ƒZ&d%d&„Z'd'd(„Z(d)d*„Z)d+d,„Z*d-d.„Z+d/d0„Z,e-dœd1d2„Z.e+e,a/a0d3d4d,d*gZ1t0Z2t/Z3dS)5ae
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Úsizeof)Úwhich)ÚPyperclipExceptionÚPyperclipWindowsException)Úfind_stack_levelZDISPLAYz·
    Pyperclip could not find a copy/paste mechanism for your system.
    For more information, please visit
    https://pyperclip.readthedocs.io/en/latest/#not-implemented-error
    zutf-8ÚWindowsÚwherercCstjt|gtjtjddkS)N)ÚstdoutÚstderrr)Ú
subprocessÚcallÚ    WHICH_CMDÚPIPE)Úname©rúSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\pandas/io/clipboard/__init__.pyÚ_executable_existsYsÿýÿr©ÚreturncCs2ttttf}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ÚtypeÚ__name__)ÚtextZ acceptedTypesrrrÚ_stringifyTextbs  
ÿr!cCsdd„}dd„}||fS)Nc    Ss@t|ƒ}tjddgtjdd}|j| t¡dW5QRXdS)NÚpbcopyÚwT©ÚstdinÚ    close_fds©Úinput©r!rÚPopenrÚ communicateÚencodeÚENCODING©r ÚprrrÚcopy_osx_pbcopymsÿz2init_osx_pbcopy_clipboard.<locals>.copy_osx_pbcopyc    Ss8tjddgtjdd}| ¡d}W5QRX| t¡S)NZpbpasteÚrT©r r&r©rr*rr+Údecoder-©r/r rrrÚpaste_osx_pbcopytsÿz3init_osx_pbcopy_clipboard.<locals>.paste_osx_pbcopyr)r0r6rrrÚinit_osx_pbcopy_clipboardlsr7cCsdd„}dd„}||fS)NcSsPt|ƒ}tj |¡ ¡}| tj¡}tj     ¡}| 
tj gd¡|  |tj ¡dS)z!Copy string argument to clipboardN) r!Ú
FoundationZNSStringZstringWithString_ZnsstringZdataUsingEncoding_ZNSUTF8StringEncodingÚAppKitÚ NSPasteboardÚgeneralPasteboardZdeclareTypes_owner_ÚNSStringPboardTypeZsetData_forType_)r ZnewStrZnewDataÚboardrrrÚcopy_osx_pyobjcs  
z2init_osx_pyobjc_clipboard.<locals>.copy_osx_pyobjccSstj ¡}| tj¡}|S)zReturns contents of clipboard)r9r:r;ZstringForType_r<)r=ÚcontentrrrÚpaste_osx_pyobjcˆs
 z3init_osx_pyobjc_clipboard.<locals>.paste_osx_pyobjcr)r>r@rrrÚinit_osx_pyobjc_clipboard~s    rAc s–zddlmaWnFtk
rVzddlmaWn tk
rPddlmaYnXYnXt ¡‰ˆdkrptgƒ‰‡fdd„}tdœ‡fdd„ }||fS)Nr)Ú QApplicationcst|ƒ}ˆ ¡}| |¡dS©N)r!Ú    clipboardZsetText)r Úcb©ZapprrÚcopy_qt¢sz"init_qt_clipboard.<locals>.copy_qtrcsˆ ¡}t| ¡ƒSrC)rDrr )rErFrrÚpaste_qt§sz#init_qt_clipboard.<locals>.paste_qt)Zqtpy.QtWidgetsrBÚ ImportErrorZPyQt5.QtWidgetsZ PyQt4.QtGuiÚinstancer)rGrHrrFrÚinit_qt_clipboard‘s rKcs0d‰d‰d‡‡fdd„    }d    ‡‡fdd„    }||fS)
NÚcr/Fc    sNt|ƒ}ˆ}|rˆ}tjdd|gtjdd}|j| t¡dW5QRXdS)NÚxclipú
-selectionTr$r'r))r ÚprimaryÚ    selectionr/©ZDEFAULT_SELECTIONZPRIMARY_SELECTIONrrÚ
copy_xclip²sÿz(init_xclip_clipboard.<locals>.copy_xclipc    sLˆ}|r ˆ}tjdd|dgtjtjdd}| ¡d}W5QRX| t¡S)NrMrNú-oT©r rr&rr3)rOrPr/r rQrrÚ paste_xclip¼s
üz)init_xclip_clipboard.<locals>.paste_xclip)F)Fr)rRrUrrQrÚinit_xclip_clipboard®s
 
rVcs0d‰d‰d‡‡fdd„    }d    ‡‡fdd„    }||fS)
Nz-bz-pFc    sNt|ƒ}ˆ}|rˆ}tjd|dgtjdd}|j| t¡dW5QRXdS)NÚxselz-iTr$r'r))r rOÚselection_flagr/rQrrÚ    copy_xselÑsÿz&init_xsel_clipboard.<locals>.copy_xselc    sFˆ}|r ˆ}tjd|dgtjdd}| ¡d}W5QRX| t¡S)NrWrSTr2rr3)rOrXr/r rQrrÚ
paste_xselÛsÿz'init_xsel_clipboard.<locals>.paste_xsel)F)Fr)rYrZrrQrÚinit_xsel_clipboardÍs
 
 
r[cCsdd„}dd„}||fS)Nc    SsFt|ƒ}tjdddd| t¡gtjdd}|jddW5QRXdS)NÚqdbusúorg.kde.klipperú/klipperZsetClipboardContentsTr$r')r!rr*r,r-rr+r.rrrÚ copy_klipperésû÷
z,init_klipper_clipboard.<locals>.copy_klipperc    Ssttjddddgtjdd}| ¡d}W5QRX| t¡}t|ƒdksLt‚| d¡sZt‚| d¡rp|dd    …}|S)
Nr\r]r^ZgetClipboardContentsTr2rÚ
éÿÿÿÿ)    rr*rr+r4r-ÚlenÚAssertionErrorÚendswith)r/r ZclipboardContentsrrrÚ paste_klipperøs
ý
 
 z-init_klipper_clipboard.<locals>.paste_klipperr)r_rerrrÚinit_klipper_clipboardèsrfcCsdd„}tdœdd„}||fS)Nc    Ss\t|ƒ}|dkr tjdtƒdd|kr8tjdtƒdtddƒ}| |¡W5QRXdS)NÚz]Pyperclip cannot copy a blank string to the clipboard on Cygwin. This is effectively a no-op.©Ú
stacklevelú z0Pyperclip cannot handle \r characters on Cygwin.ú/dev/clipboardr#)r!ÚwarningsÚwarnr
ÚopenÚwrite)r ÚfdrrrÚcopy_dev_clipboardsýþ z8init_dev_clipboard_clipboard.<locals>.copy_dev_clipboardrc    Ss tdƒ}| ¡}W5QRX|S)Nrk)rnÚread)rpr?rrrÚpaste_dev_clipboard s
z9init_dev_clipboard_clipboard.<locals>.paste_dev_clipboard)r)rqrsrrrÚinit_dev_clipboard_clipboardsrtcCsGdd„dƒ}|ƒ|ƒfS)Nc@s"eZdZdd„Zedœdd„ZdS)z/init_no_clipboard.<locals>.ClipboardUnavailablec_s ttƒ‚dSrC)rÚ
EXCEPT_MSG)ÚselfÚargsÚkwargsrrrÚ__call__*sz8init_no_clipboard.<locals>.ClipboardUnavailable.__call__rcSsdS)NFr)rvrrrÚ__bool__-sz8init_no_clipboard.<locals>.ClipboardUnavailable.__bool__N)rÚ
__module__Ú __qualname__ryrrzrrrrÚClipboardUnavailable)sr}r)r}rrrÚinit_no_clipboard(sr~cs2eZdZddœ‡fdd„ Zdd„Zdd„Z‡ZS)    Ú CheckedCallNrcstƒ d|¡dS)NÚf)ÚsuperÚ __setattr__)rvr€©Ú    __class__rrÚ__init__5szCheckedCall.__init__cGs(|j|Ž}|s$tƒr$td|jjƒ‚|S)NzError calling )r€rr    r)rvrwÚretrrrry8s
 
zCheckedCall.__call__cCst|j||ƒdSrC)Úsetattrr€)rvÚkeyÚvaluerrrr‚>szCheckedCall.__setattr__)rr{r|r…ryr‚Ú __classcell__rrrƒrr4src sØddlmamamamamamamamam    a    m
a
m a t j }t  d¡}t|jjƒ‰tt    t    ttttttttt
g ˆ_tˆ_t|jjƒ‰tgˆ_tˆ_|jj‰tgˆ_tˆ_t|jjƒ‰gˆ_tˆ_t|jjƒ‰gˆ_tˆ_t|jjƒ‰t gˆ_tˆ_t|jjƒ‰ t tgˆ _tˆ _t|jjƒ‰    t tgˆ    _tˆ    _t|jjƒ‰
tgˆ
_t
ˆ
_t|jjƒ‰ tgˆ _tˆ _t|jƒ‰ t gˆ _t ˆ _d‰d‰t!j"‡‡fdd„ƒ‰t!j"‡‡fdd    „ƒ‰‡‡‡‡‡    ‡
‡ ‡ ‡ ‡f
d
d „}‡‡‡fd d „}||fS)Nr) ÚBOOLÚDWORDÚHANDLEÚHGLOBALÚ    HINSTANCEÚHMENUÚHWNDÚINTÚLPCSTRÚLPVOIDÚUINTÚmsvcrtéé c 3s8ˆddddddddddddƒ }z
|VW5ˆ|ƒXdS)z=
        Context that provides a valid Windows hwnd.
        rsSTATICNr)Úhwnd)ÚsafeCreateWindowExAÚsafeDestroyWindowrrÚwindow’s"ÿ
z&init_windows_clipboard.<locals>.windowc3sZt ¡d}d}t ¡|kr6ˆ|ƒ}|r*q6t d¡q|sBtdƒ‚z
dVW5ˆƒXdS)zˆ
        Context manager that opens the clipboard and prevents
        other applications from modifying the clipboard content.
        gà?Fg{®Gáz„?zError calling OpenClipboardN)ÚtimeÚsleepr    )r™ÚtÚsuccess)Ú OpenClipboardÚsafeCloseClipboardrrrD¡s       
z)init_windows_clipboard.<locals>.clipboardc
s’t|ƒ}ˆ    ƒz}ˆ|ƒfˆƒ|rzˆ|ƒd}ˆˆ|ttƒƒ}ˆ|ƒ}t t|ƒt|ƒ|ttƒ¡ˆ|ƒˆˆ|ƒW5QRXW5QRXdS)Né)r!rrÚctypesÚmemmover)r r™ÚcountÚhandleZ locked_handle)
ÚCF_UNICODETEXTÚ GMEM_MOVEABLErDÚsafeEmptyClipboardÚsafeGlobalAllocÚsafeGlobalLockÚsafeGlobalUnlockÚsafeSetClipboardDataÚwcslenrœrrÚ copy_windows¹s
 
ýz,init_windows_clipboard.<locals>.copy_windowsc
sDˆdƒ2ˆˆƒ}|s$W5QR£dSt|ƒjW5QR£SQRXdS)Nrg)rr‰)r§)r¨rDÚsafeGetClipboardDatarrÚ paste_windowsÚs
 
z-init_windows_clipboard.<locals>.paste_windows)#Zctypes.wintypesr‹rŒrrŽrrr‘r’r“r”r•r¤ÚwindllÚCDLLrZuser32ZCreateWindowExAÚargtypesÚrestypeZ DestroyWindowr¡ZCloseClipboardZEmptyClipboardZGetClipboardDataZSetClipboardDataÚkernel32Z GlobalAllocrZ
GlobalLockZ GlobalUnlockr¯rÚ
contextlibÚcontextmanager)r³r–r°r²r)r¨r©r¡rDr¢ršr›rªr±r«r¬r­r®r¯rœrÚinit_windows_clipboardBsr4
 ô     
 
 
! rºcCsdd„}dd„}||fS)Nc    Ss>t|ƒ}tjdgtjdd}|j| t¡dW5QRXdS)Nzclip.exeTr$r'r)r.rrrÚcopy_wslész$init_wsl_clipboard.<locals>.copy_wslc    SsFtjdddgtjtjdd}| ¡d}W5QRX|dd… t¡S)Nzpowershell.exez-commandz Get-ClipboardTrTréþÿÿÿr3r5rrrÚ    paste_wslîsüz%init_wsl_clipboard.<locals>.paste_wslr)r»r½rrrÚinit_wsl_clipboardès r¾cCs~dt ¡ ¡kr4tj d¡rPtjdtƒdt    ƒSntj
dksJt ¡dkrPt ƒSt ¡dkrjt dƒrjt ƒStj
d    ks€t ¡d
kr¶zd d lad d laWntk
r®tƒYSXtƒStrxtd ƒrÊtƒStdƒrØtƒStdƒrîtdƒrîtƒSz d d laWnvtk
rpz d d laWnHtk
r`z d d laWntk
rLYnXtƒYYSYn XtƒYSYnXtƒStƒS)z]
    Determine the OS/platform and set the copy() and paste() functions
    accordingly.
    ÚcygwinrkzcPyperclip's support for Cygwin is not perfect, see https://github.com/asweigart/pyperclip/issues/55rhÚntr ÚLinuxz wslconfig.exeÚmacÚDarwinrNrWrMÚklipperr\)ÚplatformÚsystemÚlowerÚosÚpathÚexistsrlrmr
rtrrºrr¾r9r8rIr7rAÚ HAS_DISPLAYrr[rVrfZqtpyZPyQt5ZPyQt4rKr~rrrrÚdetermine_clipboardþsR    ÿ ý      rÌc    CsRttttttttdœ}||kr@dd„|Dƒ}tdd     |¡›ƒ‚||ƒ\a
a dS)aÒ
    Explicitly sets the clipboard mechanism. The "clipboard mechanism" is how
    the copy() and paste() functions interact with the operating system to
    implement the copy/paste feature. The clipboard parameter must be one of:
        - pbcopy
        - pyobjc (default on macOS)
        - qt
        - xclip
        - xsel
        - klipper
        - windows (default on Windows)
        - no (this is what is set when no clipboard mechanism can be found)
    )r"ZpyobjcZqtrMrWrÄZwindowsÚnocSsg|] }t|ƒ‘qSr)Úrepr)Ú.0Ú_rrrÚ
<listcomp>csz!set_clipboard.<locals>.<listcomp>zArgument must be one of z, N) r7rArKrVr[rfrºr~Ú
ValueErrorÚjoinÚcopyÚpaste)rDZclipboard_typesZallowed_clipboard_typesrrrÚ set_clipboardGsø ÿrÖcCstƒ\aat|ƒS)aD
    A stub function for copy(), which will load the real copy() function when
    called so that the real copy() function is used for later calls.
 
    This allows users to import pyperclip without having determine_clipboard()
    automatically run, which will automatically select a clipboard mechanism.
    This could be a problem if it selects, say, the memory-heavy PyQt4 module
    but the user was just going to immediately call set_clipboard() to use a
    different clipboard mechanism.
 
    The lazy loading this stub function implements gives the user a chance to
    call set_clipboard() to pick another clipboard mechanism. Or, if the user
    simply calls copy() or paste() without calling set_clipboard() first,
    will fall back on whatever clipboard mechanism that determine_clipboard()
    automatically chooses.
    ©rÌrÔrÕ)r rrrÚlazy_load_stub_copyls
rØcCstƒ\aatƒS)aG
    A stub function for paste(), which will load the real paste() function when
    called so that the real paste() function is used for later calls.
 
    This allows users to import pyperclip without having determine_clipboard()
    automatically run, which will automatically select a clipboard mechanism.
    This could be a problem if it selects, say, the memory-heavy PyQt4 module
    but the user was just going to immediately call set_clipboard() to use a
    different clipboard mechanism.
 
    The lazy loading this stub function implements gives the user a chance to
    call set_clipboard() to pick another clipboard mechanism. Or, if the user
    simply calls copy() or paste() without calling set_clipboard() first,
    will fall back on whatever clipboard mechanism that determine_clipboard()
    automatically chooses.
    r×rrrrÚlazy_load_stub_paste‚s
rÙcCsttkottkSrC)rÔrØrÕrÙrrrrÚ is_available˜srÚrÔrÕ)4Ú__doc__Ú __version__r¸r¤rrrrrrÈrÅÚshutilrrrrlZ pandas.errorsrr    Zpandas.util._exceptionsr
ÚgetenvrËrur-rÆrrrr!r7rArKrVr[rfrtr~rrºr¾rÌrÖrØrÙrrÚrÔrÕÚ__all__Z clipboard_getZ clipboard_setrrrrÚ<module>sR+  
     
& 'I%