B
    ñ¶I`0#  ã               @   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"œZd#d$„ Zd%d&„ Zd'd(„ Zd)d*„ Zd+d,„ Zd-d.„ Zd2d0d1„ZdS )3é    Né   )ÚImage)zPIL._imagingZPILLOW_VERSION)zPIL._tkinter_finderN)zPIL._imagingftZfreetype2_version)zPIL._imagingcmsZlittlecms_version)z	PIL._webpZwebpdecoder_version)ÚpilÚtkinterÚ	freetype2Ú
littlecms2Úwebpc             C   sH   | t krtd| › �ƒ‚t |  \}}yt|ƒ dS  tk
rB   dS 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__ÚImportError)ÚfeatureÚmoduleÚver© r   ú0/tmp/pip-unpacked-wheel-wndzrte2/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>=   s    z)get_supported_modules.<locals>.<listcomp>)r	   r   r   r   r   Úget_supported_modules9   s    r   )ZjpegZjpeglib)Zjpeg2kZjp2klib)ÚzipÚzlib)Úlibtiffr   )ÚjpgÚjpg_2000r   r   c             C   s4   | t krtd| › �ƒ‚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   ÚcodecÚlibr   r   r   Úcheck_codecH   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_codecX   s    r*   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   q   s    z(get_supported_codecs.<locals>.<listcomp>)r    r   r   r   r   Úget_supported_codecsm   s    r+   )z	PIL._webpZHAVE_WEBPANIMN)z	PIL._webpZHAVE_WEBPMUXN)z	PIL._webpZHAVE_TRANSPARENCYN)zPIL._imagingftZ	HAVE_RAQMZraqm_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Úlibjpeg_turboÚlibimagequantÚxcbc             C   sV   | t krtd| › �ƒ‚t |  \}}}yt|dgd�}t||ƒS  tk
rP   dS 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   Úflagr   Zimported_moduler   r   r   Úcheck_feature   s    
r6   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   )r6   r4   r   r   )r   r   r5   r   r   r   r   Úversion_feature“   s    r7   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   )r6   )r   r   r   r   r   r   ¨   s    z*get_supported_features.<locals>.<listcomp>)r4   r   r   r   r   Úget_supported_features¤   s    r8   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%   r4   r6   ÚwarningsÚwarn)r   r   r   r   Úcheck«   s    r=   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    r*   r4   r7   )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   Úextendr8   r+   )Úretr   r   r   Úget_supportedÍ   s    r@   Tc          	   C   sî  | 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	�rv|dk}|dk�rRtdd„ | d¡D ƒƒdk }|�r\dnd}td|d||| d� ntd|d| d� qÞtd|d| d� qÞW td| d� |�rêt t¡}x&tj ¡ D ]\}	}
||
  |	¡ �qÄW �xttjƒD ]ø}
|
› }|
tjk�r|› dtj|
 › �}t|| d� |
|k�rNtd d t||
 ƒ¡¡| d� g }|
tjk�rh| 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� �qîW dS )%aF  
    Prints information about this installation of Pillow.
    This function can be called with ``python -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)r.   zWEBP Transparency)r-   ZWEBPMUX)r,   zWEBP Animation)r   ZJPEG)r   zOPENJPEG (JPEG2000))r   zZLIB (PNG/ZIP))r   ZLIBTIFF)r/   zRAQM (Bidirectional Text))r1   z#LIBIMAGEQUANT (Quantization method))r2   zXCB (X protocol)r   r0   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>Ú.)r9   é   zcompiled forZloadedz---zsupport ok,z
support okz***zsupport not installedú zExtensions: {}z, ÚopenÚsaveZsave_allÚdecodeÚencodezFeatures: {})$ÚsysÚstdoutr   ÚinitÚprintr3   Ú__version__r)   Ú
splitlinesÚstripÚosÚpathÚdirnameÚ__file__r"   r=   r6   r7   Útupler(   ÚcollectionsÚdefaultdictÚlistZ	EXTENSIONÚitemsÚappendÚsortedZIDZMIMEÚformatÚjoinZOPENZSAVEZSAVE_ALLZDECODERSZENCODERS)ÚoutZsupported_formatsÚ
py_versionÚnamer   ÚvZversion_staticÚtÚ
extensionsÚextÚiÚliner4   r   r   r   ÚpilinfoØ   sp    










ri   )NT)rX   rS   rL   r;   r3   Ú r   r	   r   r   r   r    r%   r*   r+   r4   r6   r7   r8   r=   r)   r@   ri   r   r   r   r   Ú<module>   sD   