
    e%              
          d dl mZ 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 Z
d Zd ZdddddZd Zd Zd Zdddddddddd	Zd  Zd! Zd" Zd# Zd$ Zd% Zd'd&Zy)(    )annotationsN   )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                    | t         vrd|  }t        |      t         |    \  }}	 t        |       y# t        $ r Y yt        $ r(}t        j                  t        |             Y d}~yd}~ww xY 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 TFN)modules
ValueError
__import__ModuleNotFoundErrorImportErrorwarningswarnstr)featuremsgmoduleverexs        ./usr/lib/python3/dist-packages/PIL/features.pycheck_moduler"      sn     gy)o'"KFC6  c"gs   2 	A-A-A((A-c                h    t        |       syt        |    \  }}|yt        t        ||g      |      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   s      r!   version_moduler'   -   s;      '"KFC
{:fu5s;;    c                 L    t         D  cg c]  } t        |       s|  c} S c c} w )z4
    :returns: A list of all supported modules.
    )r   r"   fs    r!   get_supported_modulesr,   ?   s     2!,q/A222   !!)jpegjpeglib)jpeg2kjp2klib)zipzlib)libtiffr4   )jpgjpg_2000r3   r4   c                    | t         vrd|  }t        |      t         |    \  }}|dz   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   r   codeclibs       r!   check_codecr>   N   sG     fwi(oJE3:UZZ00r(   c                    t        |       syt        |    \  }}t        t        j                  |dz         }| dk(  r&|j                  d      d   j                  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_versionr4   
r   zVersion r   )r>   r9   r&   r   r;   split)r   r<   r=   versions       r!   version_codecrD   _   sb     wJE3ejj#
"23G)}}T"1%++J7::Nr(   c                 L    t         D  cg c]  } t        |       s|  c} S c c} w )z3
    :returns: A list of all supported codecs.
    )r9   r>   r*   s    r!   get_supported_codecsrF   t   s     0!QA000r-   )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                    | t         vrd|  }t        |      t         |    \  }}}	 t        |dg      }t        ||      S # t        $ r Y yt
        $ r(}t        j                  t        |             Y d}~yd}~ww xY 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   r   r   )r   r   r   flagr   imported_moduler    s          r!   check_featurerc      s     h 	*o )FD#$Vug>--  c"gs   A 	A<A<A77A<c                j    t        |       syt        |    \  }}}|yt        t        ||g      |      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$   )rc   r`   r&   r   )r   r   ra   r   s       r!   version_featurere      s>     ! )FD#
{:fu5s;;r(   c                 L    t         D  cg c]  } t        |       s|  c} S c c} w )z5
    :returns: A list of all supported features.
    )r`   rc   r*   s    r!   get_supported_featuresrg      s      4!=#3A444r-   c                    | t         v rt        |       S | t        v rt        |       S | t        v rt        |       S t        j                  d|  dd       y)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"   r9   r>   r`   rc   r   r   r   s    r!   checkrl      sX     'G$$&7##(W%%MM%gYb1a@r(   c                v    | t         v rt        |       S | t        v rt        |       S | t        v rt        |       S y)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'   r9   rD   r`   re   rk   s    r!   rC   rC      s@     'g&&&W%%(w''r(   c                 ~    t               } | j                  t                      | j                  t                      | S )zJ
    :returns: A list of all supported modules, features, and codecs.
    )r,   extendrg   rF   )rets    r!   get_supportedrq      s1    
  
!CJJ%'(JJ#%&Jr(   c                    | t         j                  } t        j                          t	        d|        t	        dt
        j                   |        t         j                  j                         }t	        d|d   j                          |        |dd D ]   }t	        d|j                          |        " t	        d|        t	        d	t        j                  j                  t        j                         |        t	        d
t        j                  j                  t        j                  j                         |        t	        d|        dD ]  \  }}t        |      r|dk(  rt!        d      rdt#        d      z   }nt        |      }|j|dv }|dk(  r$t%        d |j'                  d      D              dk  }|rdnd}|dk(  r dD ]  }t#        |      }	|	|d| d|	 z  } t	        d|d|||        t	        d|d|        t	        d|d|         t	        d|        |rt)        j*                  t,              }
t        j.                  j1                         D ]  \  }}|
|   j3                  |        t5        t        j6                        D ]a  }| }|t        j8                  v r| dt        j8                  |    }t	        ||        ||
v r7t	        dj;                  dj=                  t5        |
|                     |        g }|t        j>                  v r|j3                  d        |t        j@                  v r|j3                  d!       |t        jB                  v r|j3                  d"       |t        jD                  v r|j3                  d#       |t        jF                  v r|j3                  d$       t	        d%j;                  dj=                  |            |        t	        d|        d yy)&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)rW   zWEBP Transparency)rV   WEBPMUX)rU   zWEBP Animation)r5   JPEG)r6   zOPENJPEG (JPEG2000))r3   zZLIB (PNG/ZIP))r4   LIBTIFF)rX   zRAQM (Bidirectional Text))r\   z#LIBIMAGEQUANT (Quantization method))r]   zXCB (X protocol)r5   r[   zlibjpeg-turbo )r   r5   r   c              3  2   K   | ]  }t        |        y w)N)int).0xs     r!   	<genexpr>zpilinfo.<locals>.<genexpr>   s     *Ha3q6*Hs   .)ri      zcompiled forloadedrX   )rY   rZ   z,  z---zsupport ok,z
support okz***zsupport not installedzExtensions: {}opensavesave_alldecodeencodezFeatures: {})$sysstdoutr   initprintr_   __version__rC   
splitlinesstripospathdirname__file__r;   rl   rc   re   tuplerB   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liner`   s                  r!   pilinfor      st    {jj	JJL	(	GCOO$
%C0'')J	GJqM'')*
+#6 n 8

((*+,378	(	
%bggooenn&E%FG 

%bggooejj6I6I&J%KL 
( %Eg" ;u}!?$'GGDM}!%!7<'%**H1773<*H%H6%QN&4N(6>4 /,Q/>2aS".A/ eWmQDeWl=%"9DK%EL 
( ,,T2
oo++- 	&FCqM  %	& ! 	&ASDEJJqA0$S!J$++DIIfZ]6K,LMTW HEJJ'EJJ'ENN"
+ENN")ENN").''		((;<3G(%1	& r(   )NT)
__future__r   r   r   r   r   r_    r   r   r"   r'   r,   r9   r>   rD   rF   r`   rc   re   rg   rl   rC   rq   r    r(   r!   <module>r      s    "  	 
  
  .48:00<$3 %%	
1"*1 63;;DGSQ-
0<"5$ f&r(   