B
    eAd%              
   @   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dddd	Zd
d Zdd Z	dd Z
dddddZdd Zdd Zdd Zdddddd d!d"d#d$	Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd4d2d3ZdS )5    N   )Image)zPIL._imagingZPILLOW_VERSION)zPIL._tkinter_finderZ
tk_version)zPIL._imagingftZfreetype2_version)zPIL._imagingcmsZlittlecms_version)z	PIL._webpZwebpdecoder_version)piltkinter	freetype2
littlecms2webpc          
   C   sz   | t krd|  }t|t |  \}}yt| dS  tk
rF   dS  tk
rt } ztt| dS d}~X Y nX dS )z
    Checks if a module is available.

    :param feature: The module to check for.
    :returns: ``True`` if available, ``False`` otherwise.
    :raises ValueError: If the module is not defined in this version of Pillow.
    zUnknown module TFN)modules
ValueError
__import__ModuleNotFoundErrorImportErrorwarningswarnstr)featuremsgmoduleverex r   >/var/www/html/venv/lib/python3.7/site-packages/PIL/features.pycheck_module   s    
r   c             C   s8   t | sdS t|  \}}|dkr$dS tt||gd|S )z
    :param feature: The module to check for.
    :returns:
        The loaded version number as a string, or ``None`` if unknown or not available.
    :raises ValueError: If the module is not defined in this version of Pillow.
    N)fromlist)r   r	   getattrr   )r   r   r   r   r   r   version_module+   s    r   c               C   s   dd t D S )z4
    :returns: A list of all supported modules.
    c             S   s   g | ]}t |r|qS r   )r   ).0fr   r   r   
<listcomp>A   s    z)get_supported_modules.<locals>.<listcomp>)r	   r   r   r   r   get_supported_modules=   s    r   )ZjpegZjpeglib)Zjpeg2kZjp2klib)zipzlib)libtiffr"   )jpgjpg_2000r!   r"   c             C   s8   | t krd|  }t|t |  \}}|d ttjkS )z
    Checks if a codec is available.

    :param feature: The codec to check for.
    :returns: ``True`` if available, ``False`` otherwise.
    :raises ValueError: If the codec is not defined in this version of Pillow.
    zUnknown codec _encoder)codecsr
   dirr   core)r   r   codeclibr   r   r   check_codecL   s
    
r+   c             C   sL   t | sdS t|  \}}ttj|d }| dkrH|dd dd S |S )a  
    :param feature: The codec to check for.
    :returns:
        The version number as a string, or ``None`` if not available.
        Checked at compile time for ``jpg``, run-time otherwise.
    :raises ValueError: If the codec is not defined in this version of Pillow.
    N_versionr"   
r   zVersion r   )r+   r&   r   r   r(   split)r   r)   r*   versionr   r   r   version_codec]   s    r0   c               C   s   dd t D S )z3
    :returns: A list of all supported codecs.
    c             S   s   g | ]}t |r|qS r   )r+   )r   r   r   r   r   r   v   s    z(get_supported_codecs.<locals>.<listcomp>)r&   r   r   r   r   get_supported_codecsr   s    r1   )z	PIL._webpZHAVE_WEBPANIMN)z	PIL._webpZHAVE_WEBPMUXN)z	PIL._webpZHAVE_TRANSPARENCYN)zPIL._imagingftZ	HAVE_RAQMZraqm_version)zPIL._imagingftZHAVE_FRIBIDIZfribidi_version)zPIL._imagingftZHAVE_HARFBUZZZharfbuzz_version)zPIL._imagingZHAVE_LIBJPEGTURBOZlibjpeg_turbo_version)zPIL._imagingZHAVE_LIBIMAGEQUANTZimagequant_version)zPIL._imagingZHAVE_XCBN)		webp_animwebp_muxtransp_webpraqmfribidiharfbuzzlibjpeg_turbolibimagequantxcbc          
   C   s   | t krd|  }t|t |  \}}}yt|dgd}t||S  tk
rT   dS  tk
r } ztt| dS d}~X Y nX dS )z
    Checks if a feature is available.

    :param feature: The feature to check for.
    :returns: ``True`` if available, ``False`` if unavailable, ``None`` if unknown.
    :raises ValueError: If the feature is not defined in this version of Pillow.
    zUnknown feature PIL)r   N)	featuresr
   r   r   r   r   r   r   r   )r   r   r   flagr   Zimported_moduler   r   r   r   check_feature   s    

r>   c             C   s:   t | sdS t|  \}}}|dkr&dS tt||gd|S )z
    :param feature: The feature to check for.
    :returns: The version number as a string, or ``None`` if not available.
    :raises ValueError: If the feature is not defined in this version of Pillow.
    N)r   )r>   r<   r   r   )r   r   r=   r   r   r   r   version_feature   s    r?   c               C   s   dd t D S )z5
    :returns: A list of all supported features.
    c             S   s   g | ]}t |r|qS r   )r>   )r   r   r   r   r   r      s    z*get_supported_features.<locals>.<listcomp>)r<   r   r   r   r   get_supported_features   s    r@   c             C   sJ   | t krt| S | tkr t| S | tkr0t| S tjd|  ddd dS )z
    :param feature: A module, codec, or feature name.
    :returns:
        ``True`` if the module, codec, or feature is available,
        ``False`` or ``None`` otherwise.
    zUnknown feature 'z'.   )
stacklevelF)r	   r   r&   r+   r<   r>   r   r   )r   r   r   r   check   s    rC   c             C   s4   | t krt| S | tkr t| S | tkr0t| S dS )z
    :param feature:
        The module, codec, or feature to check for.
    :returns:
        The version number as a string, or ``None`` if unknown or not available.
    N)r	   r   r&   r0   r<   r?   )r   r   r   r   r/      s    r/   c              C   s"   t  } | t  | t  | S )zJ
    :returns: A list of all supported modules, features, and codecs.
    )r   extendr@   r1   )retr   r   r   get_supported   s    rF   Tc          	   C   s0  | dkrt j} t  td| d tdtj | d t j }td|d 	  | d x*|dd D ]}td|	  | d qhW td| d td	t
jtj | d td
t
jtjj | d td| d xdD ]\}}t|r|dkrtdrdtd }nt|}|dk	r|dk}|dkrTtdd |dD dk }|r^dnd}|dkrx4dD ],}t|}	|	dk	rr|d| d|	 7 }qrW td|d||| d ntd|d| d qtd|d| d qW td| d |r,tt}
x&tj D ]\}}|
| | qW xttjD ]}| }|tjkrZ| dtj|  }t|| d ||
krtd dt|
| | d g }|tjkr|d! |tj kr|d" |tj!kr|d# |tj"kr|d$ |tj#kr|d% td&d|| d td| d q0W dS )'aG  
    Prints information about this installation of Pillow.
    This function can be called with ``python3 -m PIL``.

    :param out:
        The output stream to print to. Defaults to ``sys.stdout`` if ``None``.
    :param supported_formats:
        If ``True``, a list of all supported image file formats will be printed.
    NzD--------------------------------------------------------------------)filezPillow zPython r   r   z       zPython modules loaded from zBinary modules loaded from ))r   zPIL CORE)r   ZTKINTER)r   Z	FREETYPE2)r   Z
LITTLECMS2)r   ZWEBP)r4   zWEBP Transparency)r3   ZWEBPMUX)r2   zWEBP Animation)r#   ZJPEG)r$   zOPENJPEG (JPEG2000))r!   zZLIB (PNG/ZIP))r"   ZLIBTIFF)r5   zRAQM (Bidirectional Text))r9   z#LIBIMAGEQUANT (Quantization method))r:   zXCB (X protocol)r#   r8   zlibjpeg-turbo )r   r#   r   c             s   s   | ]}t |V  qd S )N)int)r   xr   r   r   	<genexpr>  s    zpilinfo.<locals>.<genexpr>.)rA      zcompiled forZloadedr5   )r6   r7   z,  z---zsupport ok,z
support okz***zsupport not installedzExtensions: {}opensaveZsave_alldecodeencodezFeatures: {})$sysstdoutr   initprintr;   __version__r/   
splitlinesstripospathdirname__file__r(   rC   r>   r?   tupler.   collectionsdefaultdictlistZ	EXTENSIONitemsappendsortedZIDMIMEformatjoinZOPENZSAVEZSAVE_ALLZDECODERSZENCODERS)outZsupported_formats
py_versionnamer   vZversion_statictr   Zv2
extensionsextiliner<   r   r   r   pilinfo   sz    













rp   )NT)r^   rY   rR   r   r;    r   r	   r   r   r   r&   r+   r0   r1   r<   r>   r?   r@   rC   r/   rF   rp   r   r   r   r   <module>   sH   