Sindbad~EG File Manager

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

�

&ٜg	'�	��ddlmZddlZddlZddlZddlZddlZddlmZddl	m
Z
ddlmZgZ
d)d*d�Zd+d,d�ZGd	�d
�ZGd�de�Zej$d
k(ree�Gd�de�Zej$dk(ree�Gd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�Zej$dvr�ej4d�ree�ej4d�ree�ej4d �ree�ej4d!�ree�ej4d"�ree�Gd#�d$e�Z	dd%lmZee�e d&k(rse!ejD�d'kre#d(�ejH�ejJejDd�5Z&e#ee&gejDd'd����ddd�yy#e$rY��wxYw#1swYyxYw)-�)�annotationsN��quote)�Any�)�Imagec��t|t�rt|t�r|�}|dkDrtj|�ytj
d|�y)a$
    The :py:func:`register` function is used to register additional viewers::

        from PIL import ImageShow
        ImageShow.register(MyViewer())  # MyViewer will be used as a last resort
        ImageShow.register(MySecondViewer(), 0)  # MySecondViewer will be prioritised
        ImageShow.register(ImageShow.XVViewer(), 0)  # XVViewer will be prioritised

    :param viewer: The viewer to be registered.
    :param order:
        Zero or a negative integer to prepend this viewer to the list,
        a positive integer to append it.
    rN)�
isinstance�type�
issubclass�Viewer�_viewers�append�insert)�viewer�orders  �8/usr/local/lib/python3.12/site-packages/PIL/ImageShow.py�registerrs?���&�$��J�v�v�$>�����q�y����������6�"�c�H�tD]}|j|fd|i|��s�yy)a
    Display a given image.

    :param image: An image object.
    :param title: Optional title. Not all viewers can display the title.
    :param \**options: Additional viewer options.
    :returns: ``True`` if a suitable viewer was found, ``False`` otherwise.
    �titleTF)r�show)�imager�optionsrs    rrr3s.�����6�;�;�u�5�E�5�W�5���rc�b�eZdZUdZd
d�ZdZded<	iZded<	dd�Zdd	�Z	dd
�Z
d
d�Zdd�Zy)r
zBase class for viewers.rc��|jdvs\|jdk(r|jdvs?tj|j�}|j|k7r|j	|�}|j
|fi|��S)z�
        The main function for displaying an image.
        Converts the given image to the target format and displays it.
        )�1�RGBA�PNG)zI;16�LA)�mode�formatr�getmodebase�convert�
show_image)�selfrr�bases    rrzViewer.showGsk��
�J�J�-�'����u�$����~�)E��$�$�U�Z�Z�0�D��z�z�T�!��
�
�d�+���t���u�0��0�0rN�
str | Noner"zdict[str, Any]c��|jS)z3Return format name, or ``None`` to save as PGM/PPM.)r"�r&rs  r�
get_formatzViewer.get_format^s���{�{�rc��d}t|��)zj
        Returns the command used to display the file.
        Not implemented in the base class.
        zunavailable in base viewer)�NotImplementedError)r&�filer�msgs    r�get_commandzViewer.get_commandbs��
+��!�#�&�&rc�\�|jdd|j|�i|j��S)z+Save to temporary file and return filename.r"�)�_dumpr+rr*s  r�
save_imagezViewer.save_imagejs(���u�{�{�I�$�/�/�%�"8�I�D�L�L�I�Irc�F�|j|j|�fi|��S)zDisplay the given image.)�	show_filer4�r&rrs   rr%zViewer.show_imagens!���t�~�~�d�o�o�e�4�@��@�@rc��tjj|�st�tj|j
|fi|���y)�%
        Display given file.
        r)�os�path�exists�FileNotFoundError�systemr0�r&r;rs   rr6zViewer.show_filers<���w�w�~�~�d�#�#�#�
�	�	�"�$�"�"�4�3�7�3�4�r�r�Image.Imagerr�return�int)rrArBr(�r.�strrrrBrE)rrArBrE�r;rErrrBrC)
�__name__�
__module__�__qualname__�__doc__rr"�__annotations__rr+r0r4r%r6r2rrr
r
BsA��!�1�$�F�J��/� �G�^� �7��'�J�A�rr
c�.�eZdZdZdZddd�Zd	d�Zd
d�Zy)�
WindowsViewerzNThe default viewer on Windows is the default system application for PNG files.rrT��compress_level�save_allc��d|�d|�d�S)Nzstart "Pillow" /WAIT "z)" && ping -n 4 127.0.0.1 >NUL && del /f "�"r2�r&r.rs   rr0zWindowsViewer.get_command�s��$�T�F�+���q�
"�	
rc��tjj|�st�t	j
|j|fi|��dttd���y)r9T�CREATE_NO_WINDOW)�shell�
creationflagsr)r:r;r<r=�
subprocess�Popenr0�getattrr?s   rr6zWindowsViewer.show_file�sP���w�w�~�~�d�#�#�#�����D���T�-�W�-��!�*�.@�A�	
�
rNrDrF�rGrHrIrJr"rr0r6r2rrrMrMs��X�
�F�!"��5�G�
�rrM�win32c�.�eZdZdZdZddd�Zd	d�Zd
d�Zy)�	MacViewerz2The default viewer on macOS using ``Preview.app``.rrTrNc�F�d}d|�dt|��dt|��d�}|S)Nzopen -a Preview.app�(� z; sleep 20; rm -f z)&r�r&r.r�commands    rr0zMacViewer.get_command�s1��(���g�Y�a��d��}�,>�u�T�{�m�2�N���rc��tjj|�st�t	j
ddd|g�tjxstjd�}|rt	j|dd|g�y)r9�openz-azPreview.app�python3z-cz<import os, sys, time; time.sleep(20); os.remove(sys.argv[1])r)r:r;r<r=rX�call�sys�
executable�shutil�whichrY)r&r;rris    rr6zMacViewer.show_file�sm���w�w�~�~�d�#�#�#������}�d�;�<��^�^�>�v�|�|�I�'>�
�������R��	�
�rNrDrFr[r2rrr^r^�s��<�
�F�!"��5�G��rr^�darwinc�H�eZdZdZddd�Zejdd��Zd	d�Zy)
�
UnixViewerrrTrNc��y�Nr2rSs   r�get_command_exzUnixViewer.get_command_ex�s��rc�N�|j|fi|��d}|�dt|���S)Nrra)rqrrbs    rr0zUnixViewer.get_command�s3��%�$�%�%�d�6�g�6�q�9����!�E�$�K�=�)�)rN�r.rErrrB�tuple[str, str]rD)	rGrHrIr"r�abc�abstractmethodrqr0r2rrrnrn�s.��
�F�!"��5�G����
��
�*rrnc� �eZdZdZdd�Zdd�Zy)�	XDGViewerz3
    The freedesktop.org ``xdg-open`` command.
    c��dx}}||fS)N�xdg-openr2)r&r.rrcris     rrqzXDGViewer.get_command_ex�s��)�)��*��
�"�"rc�|�tjj|�st�t	j
d|g�y)r9rzr�r:r;r<r=rXrYr?s   rr6zXDGViewer.show_file�s0���w�w�~�~�d�#�#�#����*�d�+�,�rNrsrF�rGrHrIrJrqr6r2rrrxrx�s���#�rrxc�2�eZdZdZ	d							dd�Zdd�Zy)�
DisplayViewerz`
    The ImageMagick ``display`` command.
    This viewer supports the ``title`` parameter.
    Nc�8�dx}}|r|dt|���z
}||fS)N�displayz -title r�r&r.rrrcris      rrqzDisplayViewer.get_command_ex�s1�� )�(��*����%��,��0�0�G��
�"�"rc���tjj|�st�dg}|j	d�}|r|d|gz
}|j|�t
j|�y)r9r�rz-titler�r:r;r<r=�getrrXrY�r&r;r�argsrs     rr6zDisplayViewer.show_file�s^���w�w�~�~�d�#�#�#��{�����G�$����X�u�%�%�D����D�������rrp�r.rErr(rrrBrtrFr}r2rrrr�s6���.2�#��#� *�#�>A�#�	�#�
rrc� �eZdZdZdd�Zdd�Zy)�GmDisplayViewerz*The GraphicsMagick ``gm display`` command.c��d}d}||fS)N�gmz
gm displayr2�r&r.rrircs     rrqzGmDisplayViewer.get_command_exs���
����
�"�"rc�~�tjj|�st�t	j
dd|g�y)r9r�r�rr|r?s   rr6zGmDisplayViewer.show_file	s2���w�w�~�~�d�#�#�#����$�	�4�0�1�rNrsrFr}r2rrr�r�s��4�#�
rr�c� �eZdZdZdd�Zdd�Zy)�	EogViewerz'The GNOME Image Viewer ``eog`` command.c��d}d}||fS)N�eogzeog -nr2r�s     rrqzEogViewer.get_command_exs���
����
�"�"rc�~�tjj|�st�t	j
dd|g�y)r9r�z-nrr|r?s   rr6zEogViewer.show_files2���w�w�~�~�d�#�#�#����%��t�,�-�rNrsrFr}r2rrr�r�s��1�#�
rr�c�2�eZdZdZ	d							dd�Zdd�Zy)�XVViewerzX
    The X Viewer ``xv`` command.
    This viewer supports the ``title`` parameter.
    Nc�8�dx}}|r|dt|���z
}||fS)N�xvz -name rr�s      rrqzXVViewer.get_command_ex+s1��
 $�#��*�����u���/�/�G��
�"�"rc���tjj|�st�dg}|j	d�}|r|d|gz
}|j|�t
j|�y)r9r�rz-namerr�r�s     rr6zXVViewer.show_file5s^���w�w�~�~�d�#�#�#��v�����G�$����W�e�$�$�D����D�������rrpr�rFr}r2rrr�r�%s6���.2�#��#� *�#�>A�#�	�#�
rr�)r\rlrzr�r�r�r�c��eZdZdZdd�Zy)�
IPythonViewerz!The viewer for IPython frontends.c��t|�y)Nr)�ipython_displayr7s   rr%zIPythonViewer.show_imageUs
�����rNr@)rGrHrIrJr%r2rrr�r�Rs
��+�rr�)r��__main__�z.Syntax: python3 ImageShow.py imagefile [title])r)rztype[Viewer] | ViewerrrCrB�Nonerp)rrArr(rrrB�bool)'�
__future__rrur:rjrXrh�shlexr�typingr�rrrrr
rM�platformr^rnrxrr�r�r�rkr��IPython.displayr�r��ImportErrorrG�len�argv�print�exitre�imr2rr�<module>r�s���#�
�	�
��
����
��#�,�7�7�z�F��6�<�<�7���]�����B�<�<�8���Y��
*��
*��
��&�J��<�j��$�
��$�z��@�<�<�*�*��v�|�|�J������v�|�|�I������v�|�|�D����!��v�|�|�E������v�|�|�D������F���:�
�]���z��
�3�8�8�}�q��
�>�?�����
�	����C�H�H�Q�K�	 �B�
�d�2�%�������%�&�
!�	 ���
�	��	��
!�	 �s�%G,�G7�,G4�3G4�7H

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