o
    Z#ûa«$  ã                
   @   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)úPIL._imagingÚPILLOW_VERSION)zPIL._tkinter_finderÚ
tk_version)úPIL._imagingftÚfreetype2_version)zPIL._imagingcmsÚlittlecms_version)ú	PIL._webpÚwebpdecoder_version)ÚpilÚtkinterÚ	freetype2Ú
littlecms2Úwebpc                 C   sF   | t vrtd| › �ƒ‚t |  \}}zt|ƒ W dS  ty"   Y dS w )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 TF)ÚmodulesÚ
ValueErrorÚ
__import__ÚImportError©ÚfeatureÚmoduleÚver© r   ú./usr/lib/python3/dist-packages/PIL/features.pyÚcheck_module   s   ÿr   c                 C   s8   t | ƒsdS t|  \}}|du 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   Úversion_module'   s   r   c                   C   ó   dd„ t D ƒS )z4
    :returns: A list of all supported modules.
    c                 S   ó   g | ]}t |ƒr|‘qS r   )r   ©Ú.0Úfr   r   r   Ú
<listcomp>=   ó    z)get_supported_modules.<locals>.<listcomp>)r   r   r   r   r   Úget_supported_modules9   ó   r'   )ÚjpegÚjpeglib)Újpeg2kÚjp2klib)ÚzipÚzlib)Úlibtiffr/   )ÚjpgÚjpg_2000r.   r/   c                 C   s4   | t vrtd| › �ƒ‚t |  \}}|d ttjƒv 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   r8   c                 C   sL   t | ƒsdS t|  \}}ttj|d ƒ}| dkr$| 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   )r8   r3   r   r   r5   Úsplit)r   r6   r7   Úversionr   r   r   Úversion_codecX   s   r=   c                   C   r    )z3
    :returns: A list of all supported codecs.
    c                 S   r!   r   )r8   r"   r   r   r   r%   q   r&   z(get_supported_codecs.<locals>.<listcomp>)r3   r   r   r   r   Úget_supported_codecsm   r(   r>   )r
   ÚHAVE_WEBPANIMN)r
   ÚHAVE_WEBPMUXN)r
   ÚHAVE_TRANSPARENCYN)r   Ú	HAVE_RAQMÚraqm_version)r   ÚHAVE_FRIBIDIÚfribidi_version)r   ÚHAVE_HARFBUZZÚharfbuzz_version)r   ÚHAVE_LIBJPEGTURBOÚlibjpeg_turbo_version)r   ÚHAVE_LIBIMAGEQUANTÚimagequant_version)r   ÚHAVE_XCBN)	Ú	webp_animÚwebp_muxÚtransp_webpÚraqmÚfribidiÚharfbuzzÚlibjpeg_turboÚlibimagequantÚxcbc                 C   sT   | t vrtd| › �ƒ‚t |  \}}}zt|dgd�}t||ƒW S  ty)   Y dS w )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 ÚPILr   N)Úfeaturesr   r   r   r   )r   r   Úflagr   Úimported_moduler   r   r   Úcheck_feature�   s   ÿrZ   c                 C   s:   t | ƒsdS t|  \}}}|du 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.
    Nr   )rZ   rW   r   r   )r   r   rX   r   r   r   r   Úversion_feature•   s   r[   c                   C   r    )z5
    :returns: A list of all supported features.
    c                 S   r!   r   )rZ   r"   r   r   r   r%   ª   r&   z*get_supported_features.<locals>.<listcomp>)rW   r   r   r   r   Úget_supported_features¦   r(   r\   c                 C   sJ   | t v rt| ƒS | tv rt| ƒS | tv rt| ƒ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   r3   r8   rW   rZ   ÚwarningsÚwarn©r   r   r   r   Úcheck­   s   rb   c                 C   s4   | t v rt| ƒS | tv rt| ƒS | tv rt| ƒ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   r3   r=   rW   r[   ra   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\   r>   )Úretr   r   r   Úget_supportedÏ   s   re   Tc              	   C   s  | du rt j} t ¡  td| d� tdtj› �| d� t j ¡ }td|d  	¡ › �| d� |dd… D ]}td| 	¡ › �| d� q3td| d� td	t
j tj¡› �| d� td
t
j tjj¡› �| d� td| d� dD ]r\}}t|ƒrÖ|dkrƒtdƒrƒdtdƒ }nt|ƒ}|durÍ|dv }|dkr¡tdd„ | d¡D ƒƒdk }|r¥dnd}|dkrÂdD ]}t|ƒ}	|	durÁ|d|› d|	› �7 }q­td|d||| d� qltd|d| d� qltd|d| d� qltd| d� |�r€t t¡}
tj ¡ D ]\}}|
|  |¡ qòttjƒD ]~}|› }|tjv �r|› dtj| › �}t|| d� ||
v �r3td  d t|
| ƒ¡¡| d� g }|tjv �r@| d!¡ |tj v �rK| d"¡ |tj!v �rV| d#¡ |tj"v �ra| d$¡ |tj#v �rl| d%¡ td& d |¡¡| d� td| d� �qdS 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   ÚTKINTER)r   Ú	FREETYPE2)r   Ú
LITTLECMS2)r   ÚWEBP)rO   zWEBP Transparency)rN   ÚWEBPMUX)rM   zWEBP Animation)r0   ÚJPEG)r1   zOPENJPEG (JPEG2000))r.   zZLIB (PNG/ZIP))r/   ÚLIBTIFF)rP   zRAQM (Bidirectional Text))rT   z#LIBIMAGEQUANT (Quantization method))rU   zXCB (X protocol)r0   rS   zlibjpeg-turbo )r   r0   r   c                 s   s   � | ]}t |ƒV  qd S )N)Úint)r#   Úxr   r   r   Ú	<genexpr>  s   € zpilinfo.<locals>.<genexpr>Ú.)r]   é   zcompiled forÚloadedrP   )rQ   rR   z, ú z---zsupport ok,z
support okz***zsupport not installedzExtensions: {}ÚopenÚsaveÚsave_allÚdecodeÚencodezFeatures: {})$ÚsysÚstdoutr   ÚinitÚprintrV   Ú__version__r<   Ú
splitlinesÚstripÚosÚpathÚdirnameÚ__file__r5   rb   rZ   r[   Útupler;   ÚcollectionsÚdefaultdictÚlistÚ	EXTENSIONÚitemsÚappendÚsortedÚIDÚMIMEÚformatÚjoinÚOPENÚSAVEÚSAVE_ALLÚDECODERSÚENCODERS)ÚoutÚsupported_formatsÚ
py_versionÚnamer   ÚvÚversion_staticÚtr$   Úv2Ú
extensionsÚextÚiÚlinerW   r   r   r   ÚpilinfoÚ   s†   
þþ€

ÿ




ãr¢   )NT)r†   r�   rz   r_   rV   Ú r   r   r   r   r'   r3   r8   r=   r>   rW   rZ   r[   r\   rb   r<   re   r¢   r   r   r   r   Ú<module>   sP    û	ü÷