Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/site-packages/pyperclip/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/site-packages/pyperclip/__pycache__/__init__.cpython-312.pyc

�

%ٜgo]���dZdZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlmZmZm
Z
mZmZddlmZmZej&ddk(ZereZneZdZ	ddlmZd	�ZeZGd�de�Z Gd
�de �Z!Gd�de �Z"d�Z#d�Z$d�Z%d�Z&d�Z'd�Z(d�Z)d�Z*d�Z+Gd�de,�Z-d�Z.d�Z/d�Z0d�Z1d �Z2d!�Z3d"�Z4e2e3ca5a6gd#�Z7y#e$rd
�ZeZY�rwxYw)$a�
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, xsel, or wl-clipboard (for "wayland" sessions) via package manager.
For example, in Debian:
    sudo apt-get install xclip
    sudo apt-get install xsel
    sudo apt-get install wl-clipboard

Otherwise on Linux, you will need the qtpy or 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
    - pbcopy
    - pbpaste
    - xclip
    - xsel
    - wl-copy/wl-paste
    - 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.9.0�N)�c_size_t�sizeof�	c_wchar_p�	get_errno�c_wchar)�Union�Optional��utf-8)�whichc�*�tt|��S�N)�boolr��names �=/usr/local/lib/python3.12/site-packages/pyperclip/__init__.py�_py3_executable_existsrJs���E�$�K� � �c�t�tjd|gtjtj��dk(S)Nr)�stdout�stderrr)�
subprocess�call�PIPErs r�_py2_executable_existsrOs1��������#-�?�?�:�?�?�L�OP�Q�	Qrc��eZdZy)�PyperclipExceptionN��__name__�
__module__�__qualname__�rrrrU���rrc���eZdZ�fd�Z�xZS)�PyperclipWindowsExceptionc�`��|dtj�zz
}tt|�|�y)Nz (%s))�ctypes�WinError�superr%�__init__)�self�message�	__class__s  �rr*z"PyperclipWindowsException.__init__Ys)����7�V�_�_�.�.�.��
�'��7��@r)rr r!r*�
__classcell__�r-s@rr%r%Xs���A�Arr%c��eZdZy)�PyperclipTimeoutExceptionNrr"rrr1r1]r#rr1c��d�}d�}||fS)Nc��t|�}tjddgtjd��}|j	|jt���y)N�pbcopy�wT��stdin�	close_fds��input��_PYTHON_STR_TYPEr�Popenr�communicate�encode�ENCODING��text�ps  r�copy_osx_pbcopyz2init_osx_pbcopy_clipboard.<locals>.copy_osx_pbcopybsC����%�����h��_�#-�?�?�d�
D��	�
�
�D�K�K��1�
�2rc��tjddgtjd��}|j�\}}|j	t
�S)N�pbpaste�rT�rr8�rr=rr>�decoder@)rCrrs   r�paste_osx_pbcopyz3init_osx_pbcopy_clipboard.<locals>.paste_osx_pbcopyhsA�����i��-�$.�O�O�t�
E����������}�}�X�&�&rr")rDrKs  r�init_osx_pbcopy_clipboardrLas��3�'��,�,�,rc��d�}d�}||fS)Nc�p�t|�}tjj|�j	�}|jtj�}tjj�}|jtjgd�|j|tj�y)z!Copy string argument to clipboardN)
r<�
Foundation�NSString�stringWithString_�nsstring�dataUsingEncoding_�NSUTF8StringEncoding�AppKit�NSPasteboard�generalPasteboard�declareTypes_owner_�NSStringPboardType�setData_forType_)rB�newStr�newData�boards    r�copy_osx_pyobjcz2init_osx_pyobjc_clipboard.<locals>.copy_osx_pyobjcrs�����%���$�$�6�6�t�<�E�E�G���+�+�J�,K�,K�L���#�#�5�5�7��
�!�!�6�#<�#<�"=�t�D�
���w��(A�(A�Brc��tjj�}|jtj�}|S)zReturns contents of clipboard)rUrVrW�stringForType_rY)r]�contents  r�paste_osx_pyobjcz3init_osx_pyobjc_clipboard.<locals>.paste_osx_pyobjc{s1���#�#�5�5�7���&�&�v�'@�'@�A���rr")r^rbs  r�init_osx_pyobjc_clipboardrcqs��C���,�,�,rc���	ddlmatj����tg���fd�}�fd�}||fS#ddlmaY�9xYw)Nr)�QApplicationc�^��t|�}�j�}|j|�yr)r<�	clipboard�setText)rB�cb�apps  �r�copy_qtz"init_qt_clipboard.<locals>.copy_qt�s$�����%��
�]�]�_��
�
�
�4�rc�V���j�}t|j��Sr)rgr<rB)rirjs �r�paste_qtz#init_qt_clipboard.<locals>.paste_qt�s���
�]�]�_������	�*�*r)�qtpy.QtWidgetsre�PyQt5.QtWidgets�instance)rkrmrjs  @r�init_qt_clipboardrq�sK���
1�/��
�
�
!�C�
�{��2����
+��H����!1�0�s	�8�Ac�2���d�d�d��fd�	}d��fd�	}||fS)N�crCc����t|�}�}|r�}tjdd|gtjd��}|j	|jt���y)N�xclip�
-selectionTr6r9r;)rB�primary�	selectionrC�DEFAULT_SELECTION�PRIMARY_SELECTIONs    ��r�
copy_xclipz(init_xclip_clipboard.<locals>.copy_xclip�sT�����%��#�	��'�I����g�|�Y�?�#-�?�?�d�
D��	�
�
�D�K�K��1�
�2rc�����}|r�}tjdd|dgtjtjd��}|j�\}}|j	t
�S)Nrurv�-oT�rrr8rI)rwrxrCrrryrzs     ��r�paste_xclipz)init_xclip_clipboard.<locals>.paste_xclip�s\���#�	��'�I����g�|�Y��E�$.�O�O�$.�O�O�'+�
-����������}�}�X�&�&r�Fr")r{rryrzs  @@r�init_xclip_clipboardr��s&�������3�
'��{�"�"rc�2���d�d�d��fd�	}d��fd�	}||fS)Nz-b�-pc����t|�}�}|r�}tjd|dgtjd��}|j	|jt���y)N�xselz-iTr6r9r;)rBrw�selection_flagrCryrzs    ��r�	copy_xselz&init_xsel_clipboard.<locals>.copy_xsel�sT�����%��*���.�N����f�n�d�;�#-�?�?�d�
D��	�
�
�D�K�K��1�
�2rc����}|r�}tjd|dgtjd��}|j�\}}|j	t
�S)Nr�r}TrHrI)rwr�rCrrryrzs     ��r�
paste_xselz'init_xsel_clipboard.<locals>.paste_xsel�sQ���*���.�N����f�n�d�;�$.�O�O�t�
E����������}�}�X�&�&rr�r")r�r�ryrzs  @@r�init_xsel_clipboardr��s&�������3�'��j� � rc�(��d�d�fd�	}d�fd�	}||fS)Nr�c�6��t|�}dg}|r|j��|s)|jd�tj|d��y	tj|tj
d��}|j
|jt���y)N�wl-copyz--clearT)r8r6r9)	r<�appendr�
check_callr=rr>r?r@)rBrw�argsrCrzs    �r�copy_wlz"init_wl_clipboard.<locals>.copy_wl�su�����%���{����K�K�)�*���K�K�	�"��!�!�$�$�7��� � ��Z�_�_��M�A�
�M�M����H� 5�M�6rc����gd�}|r|j��tj|tjd��}|j	�\}}|jt�S)N)�wl-pastez-nz-trBTrH)r�rr=rr>rJr@)rwr�rCr�_stderrrzs     �r�paste_wlz#init_wl_clipboard.<locals>.paste_wl�sN���/����K�K�)�*����T�*�/�/�T�J���-�-�/�����}�}�X�&�&rr�r")r�r�rzs  @r�init_wl_clipboardr��s �����7�'��H��rc��d�}d�}||fS)Nc	��t|�}tjdddd|jt�gtj
d��}|j
d��y)N�qdbus�org.kde.klipper�/klipper�setClipboardContentsTr6r9)r<rr=r?r@rr>rAs  r�copy_klipperz,init_klipper_clipboard.<locals>.copy_klipper�sQ����%�����
�'��5K�
�[�[��
"�
$��/�/�T�
3��	
�
�
�D�
�!rc��tjgd�tjd��}|j�\}}|j	t
�}t
|�dkDsJ�|jd�sJ�|jd�r|dd}|S)N)r�r�r��getClipboardContentsTrHr�
���)rr=rr>rJr@�len�endswith)rCrr�clipboardContentss    r�
paste_klipperz-init_klipper_clipboard.<locals>.paste_klipper�s������L��?�?�d�
4���������#�M�M�(�3���$�%��)�)�)� �)�)�$�/�/�/��%�%�d�+� 1�#�2� 6�� � rr")r�r�s  r�init_klipper_clipboardr��s��"�!�"��&�&rc��d�}d�}||fS)Nc���t|�}|dk(rtjd�d|vrtjd�tdd�}|j	|�|j�y)N�z]Pyperclip cannot copy a blank string to the clipboard on Cygwin. This is effectively a no-op.�
z0Pyperclip cannot handle \r characters on Cygwin.�/dev/clipboard�wt)r<�warnings�warn�open�write�close)rB�fos  r�copy_dev_clipboardz8init_dev_clipboard_clipboard.<locals>.copy_dev_clipboardsU����%���2�:��M�M�y�z��4�<��M�M�M�N�
�"�D�
)��
�����
���
rc�^�tdd�}|j�}|j�|S)Nr��rt)r��readr�)r�ras  r�paste_dev_clipboardz9init_dev_clipboard_clipboard.<locals>.paste_dev_clipboards(��
�"�D�
)���'�'�)��
���
��rr")r�r�s  r�init_dev_clipboard_clipboardr�s��	���2�2�2rc�<�Gd�dt�}|�|�fS)Nc�$�eZdZd�Zerd�Zyd�Zy)�/init_no_clipboard.<locals>.ClipboardUnavailablec�L�d}tjdk(rd}td|z��)Nr��linuxzx
On Linux, you can run `sudo apt-get install xclip` or `sudo apt-get install xselect` to install a copy/paste mechanism.z�Pyperclip could not find a copy/paste mechanism for your system. For more information, please visit https://pyperclip.readthedocs.io/en/latest/index.html#not-implemented-error)�sys�platformr)r+r��kwargs�additionalInfos    r�__call__z8init_no_clipboard.<locals>.ClipboardUnavailable.__call__#s=���N��|�|�w�&�"]��$�&W�Zh�&h�i�
irc��y�NFr"�r+s r�__nonzero__z;init_no_clipboard.<locals>.ClipboardUnavailable.__nonzero__*���rc��yr�r"r�s r�__bool__z8init_no_clipboard.<locals>.ClipboardUnavailable.__bool__-r�rN)rr r!r��_IS_RUNNING_PYTHON_2r�r�r"rr�ClipboardUnavailabler�!s��	i� �
�
rr�)�object)r�s r�init_no_clipboardr� s"��
�v�
� �!�#7�#9�9�9rc�*��eZdZ�fd�Zd�Zd�Z�xZS)�CheckedCallc�.��tt|�d|�y)N�f)r)r��__setattr__)r+r�r-s  �rr*zCheckedCall.__init__7s���
�k�4�,�S�!�4rc��|j|�}|s,t�r"td|jjz��|S)NzError calling )r�rr%r)r+r��rets   rr�zCheckedCall.__call__:s6���d�f�f�d�m���y�{�+�,<�t�v�v���,N�O�O��
rc�2�t|j||�yr)�setattrr�)r+�key�values   rr�zCheckedCall.__setattr__@s�������U�#r)rr r!r*r�r�r.r/s@rr�r�6s���5��$rr�c�,������	�
���
������ddlmamamamamamamamam	a	m
a
matj}tjd�}t|j j"��	ttttt
t
t
t
ttttg�	_t�	_t|j j(��
tg�
_t�
_|j j*�tg�_t�_t|j j,��g�_t�_t|j j.��g�_t�_t|j j0��tg�_t�_t|j j2��ttg�_t�_t|j4j6��
tt8g�
_t�
_t|j4j:��tg�_t�_t|j4j<��tg�_t�_t|j>��t@g�_t�_d�d�tBjD�	�
fd���tBjD��fd��������
�����f
d�}�����fd	�}||fS)
Nr)�HGLOBAL�LPVOID�DWORD�LPCSTR�INT�HWND�	HINSTANCE�HMENU�BOOL�UINT�HANDLE�msvcrtr
�
c3�h�K��dddddddddddd�}	|���|�y#�|�wxYw�w)z=
        Context that provides a valid Windows hwnd.
        rsSTATICNr")�hwnd�safeCreateWindowExA�safeDestroyWindows ��r�windowz&init_windows_clipboard.<locals>.window|sG�����#�1�i��q�!�Q��1�#'��t�T�;��	$��J��d�#���d�#�s�2�%�	2�
/�2c3�(�K�tj�dz}d}tj�|kr8�|�}|rn-tjd�tj�|kr�8|std��	d����y#��wxYw�w)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�safeCloseClipboards   ��rrgz)init_windows_clipboard.<locals>.clipboard�s|�����
�I�I�K�#������i�i�k�A�o�#�D�)�G����J�J�t��	�i�i�k�A�o�
�+�,I�J�J�	!��� ��� �s$�A(B�,
B�:B�>B�	B�Bc
��
�t|�}��5}�|�5��|rv�
|�dz}�	�|tt�z�}�
|�}tjt|�t|�|tt�z��|���|�ddd�ddd�y#1swY�xYw#1swYyxYw)N�)r<rrr'�memmover)rBr��count�handle�
locked_handle�CF_UNICODETEXT�
GMEM_MOVEABLErg�safeEmptyClipboard�safeGlobalAlloc�safeGlobalLock�safeGlobalUnlock�safeSetClipboardData�wcslenr�s     ����������r�copy_windowsz,init_windows_clipboard.<locals>.copy_windows�s���� ��%��
�X���4��"�$��
#�4�L�1�,�E�,�]�-2�V�G�_�-D�F�F�$2�6�$:�M��N�N�9�]�#;�Y�t�_�e�V\�]d�Ve�Ne�f�$�V�,�(���@�!!�
�X�!���
�X�s#�	B:�BB.�B:�.B7	�3B:�:Cc����d�5���}|s
	ddd�y�|�}t|�j}�|�|cddd�S#1swYyxYw)Nr�)rr�)r�r��return_valuer�rg�safeGetClipboardDatar�r�s   �����r�
paste_windowsz-init_windows_clipboard.<locals>.paste_windows�sT���
�t�_�)�.�9�F��
��_�+�6�2�M�$�]�3�9�9�L��V�$���_�_�s�A�&A�A)#�ctypes.wintypesr�r�r�r�r�r�r�r�r�r�r�r'�windll�CDLLr��user32�CreateWindowExA�argtypes�restype�
DestroyWindowr��CloseClipboard�EmptyClipboard�GetClipboardData�SetClipboardData�kernel32�GlobalAllocr�
GlobalLock�GlobalUnlockrr�
contextlib�contextmanager)rr�rrr�r�r�rgr�r�r�r�rr�r�r�r�rr�s    @@@@@@@@@@@@@@@r�init_windows_clipboardrDsZ����G�G�G�G��]�]�F�
�[�[��
"�F�%�f�m�m�&C�&C�D��$)�6�6�5�#�s�$'��d�E�9�f�$N�� �"&���#�F�M�M�$?�$?�@��"&���� $����M�M�/�/�M�"�V�M�� �M��$�V�]�]�%A�%A�B��"$���!%���$�V�]�]�%A�%A�B��"$���!%���&�v�}�}�'E�'E�F��%)�F��!�#)�� �&�v�}�}�'E�'E�F��%)�6�N��!�#)�� �!�&�/�/�"=�"=�>�O� $�h�/�O��%�O�� ����!;�!;�<�N�&�i�N��#�N��"�6�?�?�#?�#?�@��!(�	���#���
����
'�F� �k�F�O��F�N��M��N����$��$����!��!�.A�A�< � ���&�&rc��d�}d�}||fS)Nc��t|�}tjdgtjd��}|j	|jd���y)Nzclip.exeTr6zutf-16ler9)r<rr=rr>r?rAs  r�copy_wslz$init_wsl_clipboard.<locals>.copy_wsl�sA����%�����j�\�#-�?�?�d�
D��	�
�
�D�K�K�
�3�
�4rc��d}tjddd|gtjtjd��}|j�\}}|rt	d|����	|jd�j
�}tj|�}|jd�S#t$r}td	|����d}~wwxYw)
NzO[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes((Get-Clipboard -Raw)))zpowershell.exez
-noprofilez-commandTr~zError pasting from clipboard: rzDecoding error: )
rr=rr>�	ExceptionrJ�strip�base64�	b64decode�RuntimeError)�	ps_scriptrCrr�base64_encoded�
decoded_bytes�es       r�	paste_wslz%init_wsl_clipboard.<locals>.paste_wsl�s���e�	�
���.��j�)�T�$.�O�O�$.�O�O�'+�
-�����������<�V�H�E�F�F�	7�#�]�]�7�3�9�9�;�N�"�,�,�^�<�M� �'�'��0�0���	7��!1�!��5�6�6��	7�s� AB%�%	C�.B<�<Cr")rr&s  r�init_wsl_clipboardr'�s��5�7�(�Y��rc��dtj�j�vr>tjjd�rSt
jd�t�Stjdk(stj�dk(r
t�Stj�dk(rhtjjd�rItdd�5}d	|j�j�vrt�cd
d
d
�S	d
d
d
�tjdk(stj�dk(r	d
d
lad
d
lat#�Stj(d�r t+d�rt+d�r
t-�Stj(d�rYt+d�r
t/�St+d�r
t1�St+d�rt+d�r
t3�S	d
d
lat7�St;�S#1swY��xYw#t$$r
t'�cYSwxYw#t$$rYnwxYw	d
d
lat7�S#t$$rYt;�SwxYw)z]
    Determine the OS/platform and set the copy() and paste() functions
    accordingly.
    �cygwinr�zcPyperclip's support for Cygwin is not perfect, see https://github.com/asweigart/pyperclip/issues/55�nt�Windows�Linuxz
/proc/versionrG�	microsoftN�mac�Darwinr�WAYLAND_DISPLAYr�r��DISPLAYrur��klipperr�)r��system�lower�os�path�existsr�r�r�rr�isfiler�r�r'rOrUrc�ImportErrorrL�getenv�_executable_existsr�r�r�r��qtpyrq�PyQt5r�)r�s r�determine_clipboardr>�s����8�?�?�$�*�*�,�,��7�7�>�>�*�+��M�M�A�
B�/�1�1�
���D��H�O�O�-��:�%�'�'�����G�#�������(G�
�/�3�
'�1��a�f�f�h�n�n�.�.�)�+�(�
'�.�(�

�w�w�%��8�?�?�,��8�	/���-�.�.�
�y�y�"�#�(:�9�(E�K]�^h�Ki� �"�"�

���9�	��g�&�'�)�)��f�%�&�(�(��i�(�-?��-H�)�+�+�	�
�$�&�&����_(�
'���	/�,�.�.�	/��8�	��	��	��$�&�&���	�����	�sB�*H�H�(
H%�H	�H"�!H"�%	H1�0H1�5
I�	I�Ic��tttttt
tttd�	}||vrBtddj|j�D�cgc]
}t|���c}�z��||�\a
aycc}w)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
        - pbobjc (default on Mac OS X)
        - qt
        - xclip
        - xsel
        - klipper
        - windows (default on Windows)
        - no (this is what is set when no clipboard mechanism can be found)
    )	r4�pyobjc�qtrur�zwl-clipboardr2�windows�nozArgument must be one of %sz, N)rLrcrqr�r�r�r�rr��
ValueError�join�keys�repr�copy�paste)rg�clipboard_types�_s   r�
set_clipboardrL8s���",�+��%�#�)�)�)��
�O���'��5����Ud�Ui�Ui�Uk�Cl�Uk�PQ�D��G�Uk�Cl�9m�n�o�o�-�/�)�,�.�K�D�%��Dms�Bc�2�t�\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 PyQt5 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>rHrI)rBs r�lazy_load_stub_copyrO[s��$&�'�K�D�%���:�rc�0�t�\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 PyQt5 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.
    rNr"rr�lazy_load_stub_pasterQqs��$&�'�K�D�%��7�Nrc�:�ttk7xr
ttk7Sr)rHrOrIrQr"rr�is_availablerS�s���&�&�H�5�4H�+H�Hr)rHrIrLr>)8�__doc__�__version__rrr'r5r�rr�r�r�rrrrr�typingrr	�version_infor��unicoder<�strr@�shutilrrr;r9rr!rr%r1rLrcrqr�r�r�r�r�r�r�r�rr'r>rLrOrQrSrHrI�__all__r"rr�<module>r\s8��*�V��
��
�	���
���B�B�"��'�'��*�a�/���������0��!�/��	��	�A� 2�A�
	� 2�	�
-� -�&�4#�8!�2�6'�:3�*:�,$�&�$�J'�Z�@D�N /�F�,�,I�"�#7���e�D���K�0�Q�0��0�s�C�
C�C

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists