o
    tBh/                     @   s,  d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ g Z	d)ddZ
d*ddZG d	d
 d
ZG dd deZejdkrDe
e G dd deZejdkrUe
e G dd deZG dd deZG dd deZG dd deZG dd deZG dd deZejdvredre
e edre
e ed re
e ed!re
e ed"re
e G d#d$ d$eZzd d%lmZ W n	 ey   Y nw e
e ed&kreejd'k red( e   e!ejd Z"eee"gejd'd R   W d   dS 1 sw   Y  dS dS )+    Nquote)Image   c                 C   sN   z
t | tr	|  } W n	 ty   Y nw |dkrt|  dS td|  dS )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.
    r   N)
issubclassViewer	TypeError_viewersappendinsert)viewerorder r   d/var/www/html/riverr-enterprise-integrations-main/venv/lib/python3.10/site-packages/PIL/ImageShow.pyregister   s   
r   c                 K   s*   t D ]}|j| fd|i|r dS qdS )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   optionsr   r   r   r   r   3   s
   	r   c                   @   sN   e Zd ZdZdd ZdZ	 i Z	 dd Zdd Zd	d
 Z	dd Z
dddZdS )r   zBase class for viewers.c                 K   sP   |j dv s| jdkr|j dv st|j }|j |kr||}| j|fi |S )z
        The main function for displaying an image.
        Converts the given image to the target format and displays it.
        )1RGBAPNG)zI;16LA)modeformatr   getmodebaseconvert
show_image)selfr   r   baser   r   r   r   G   s   


zViewer.showNc                 C   s   | j S )z3Return format name, or ``None`` to save as PGM/PPM.)r   r   r   r   r   r   
get_format^   s   zViewer.get_formatc                 K   s   t )zj
        Returns the command used to display the file.
        Not implemented in the base class.
        )NotImplementedErrorr   filer   r   r   r   get_commandb   s   zViewer.get_commandc                 C   s   |j dd| |i| jS )z+Save to temporary file and return filename.r   Nr   )_dumpr!   r   r    r   r   r   
save_imagei   s   zViewer.save_imagec                 K   s   | j | |fi |S )zDisplay the given image.)	show_filer'   r   r   r   r   r   r   r   m   s   zViewer.show_imagec                 K   sL   |du rd|v rt dt |d}ntdt| j|fi | dS )
        Display given file.

        Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
        and will be removed in Pillow 10.0.0 (2023-07-01). ``path`` should be used
        instead.
        Nr$   dThe 'file' argument is deprecated and will be removed in Pillow 10 (2023-07-01). Use 'path' instead.!Missing required argument: 'path'r   )warningswarnDeprecationWarningpopr   ossystemr%   r   pathr   r   r   r   r(   q   s   zViewer.show_fileN)__name__
__module____qualname____doc__r   r   r   r!   r%   r'   r   r(   r   r   r   r   r   B   s    r   c                   @   s$   e Zd ZdZdZddiZdd ZdS )WindowsViewerzNThe default viewer on Windows is the default system application for PNG files.r   compress_levelr   c                 K   s   d| d| dS )Nzstart "Pillow" /WAIT "z)" && ping -n 2 127.0.0.1 >NUL && del /f ""r   r#   r   r   r   r%      s   zWindowsViewer.get_commandN)r6   r7   r8   r9   r   r   r%   r   r   r   r   r:      s
    r:   win32c                   @   s.   e Zd ZdZdZddiZdd Zd
dd	ZdS )	MacViewerz2The default viewer on macOS using ``Preview.app``.r   r;   r   c                 K   s(   d}d| dt | dt | d}|S )Nzopen -a Preview.app( z; sleep 20; rm -f z)&r   r   r$   r   commandr   r   r   r%      s    zMacViewer.get_commandNc                 K   sZ   |du rd|v rt dt |d}ntdtddd|g ttj	dd	|g d
S )r*   Nr$   r+   r,   openz-azPreview.appz-cz<import os, sys, time; time.sleep(20); os.remove(sys.argv[1])r   )
r-   r.   r/   r0   r   
subprocesscallPopensys
executabler3   r   r   r   r(      s"   zMacViewer.show_filer5   )r6   r7   r8   r9   r   r   r%   r(   r   r   r   r   r>      s    r>   darwinc                   @   s    e Zd ZdZddiZdd ZdS )
UnixViewerr   r;   r   c                 K   s*   | j |fi |d }d| dt| S )Nr   r?   r@   )get_command_exr   rA   r   r   r   r%      s   zUnixViewer.get_commandN)r6   r7   r8   r   r   r%   r   r   r   r   rJ      s    rJ   c                   @   "   e Zd ZdZdd ZdddZdS )	XDGViewerz3
    The freedesktop.org ``xdg-open`` command.
    c                 K   s   d }}||fS )Nxdg-openr   )r   r$   r   rB   rH   r   r   r   rK      s   zXDGViewer.get_command_exNc                 K   sB   |du rd|v rt dt |d}ntdtd|g dS )r*   Nr$   r+   r,   rN   r   r-   r.   r/   r0   r   rD   rF   r3   r   r   r   r(      s   zXDGViewer.show_filer5   r6   r7   r8   r9   rK   r(   r   r   r   r   rM      s    rM   c                   @   $   e Zd ZdZdddZdddZdS )DisplayViewerz`
    The ImageMagick ``display`` command.
    This viewer supports the ``title`` parameter.
    Nc                 K   &   d }}|r|dt | 7 }||fS )Ndisplayz -title r   r   r$   r   r   rB   rH   r   r   r   rK      s   zDisplayViewer.get_command_exc                 K   h   |du rd|v rt dt |d}ntddg}|d}|r(|d|g7 }|| t| dS )	
        Display given file.

        Before Pillow 9.1.0, the first argument was ``file``. This is now deprecated,
        and ``path`` should be used instead.
        Nr$   r+   r,   rT   r   z-titler   	r-   r.   r/   r0   r   getr
   rD   rF   r   r4   r   argsr   r   r   r   r(         


zDisplayViewer.show_filer5   rP   r   r   r   r   rR      s    
rR   c                   @   rL   )GmDisplayViewerz*The GraphicsMagick ``gm display`` command.c                 K      d}d}||fS )Ngmz
gm displayr   r   r$   r   rH   rB   r   r   r   rK        zGmDisplayViewer.get_command_exNc                 K   D   |du rd|v rt dt |d}ntdtdd|g dS )rW   Nr$   r+   r,   r_   rT   r   rO   r3   r   r   r   r(   "     zGmDisplayViewer.show_filer5   rP   r   r   r   r   r]         r]   c                   @   rL   )	EogViewerz'The GNOME Image Viewer ``eog`` command.c                 K   r^   )Neogzeog -nr   r`   r   r   r   rK   :  ra   zEogViewer.get_command_exNc                 K   rb   )rW   Nr$   r+   r,   rf   z-nr   rO   r3   r   r   r   r(   ?  rc   zEogViewer.show_filer5   rP   r   r   r   r   re   7  rd   re   c                   @   rQ   )XVViewerzX
    The X Viewer ``xv`` command.
    This viewer supports the ``title`` parameter.
    Nc                 K   rS   )Nxvz -name r   rU   r   r   r   rK   Z  s   zXVViewer.get_command_exc                 K   rV   )	rW   Nr$   r+   r,   rh   r   z-namer   rX   rZ   r   r   r   r(   b  r\   zXVViewer.show_filer5   rP   r   r   r   r   rg   T  s    
rg   )r=   rI   rN   rT   r_   rf   rh   c                   @   s   e Zd ZdZdd ZdS )IPythonViewerz!The viewer for IPython frontends.c                 K   s   t | dS )Nr   )ipython_displayr)   r   r   r   r     s   zIPythonViewer.show_imageN)r6   r7   r8   r9   r   r   r   r   r   ri     s    ri   )rT   __main__   z.Syntax: python3 ImageShow.py imagefile [title])r   r5   )#r1   shutilrD   rG   r-   shlexr   PILr   r	   r   r   r   r:   platformr>   rJ   rM   rR   r]   re   rg   whichri   IPython.displayrT   rj   ImportErrorr6   lenargvprintexitrC   imr   r   r   r   <module>   sb   

H

+	'
)





 $