o
    õ·in+  ã                	   @  s  U d dl m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Zddl	m
Z
 dddd	d
ddœZdCdd„ZdDdd„ZdEdd„ZdddddœZdCdd„ZdDd d!„ZdEd"d#„Zd$d%d&d'd(d)d*d+d,œZd-ed.< dFd0d1„ZdDd2d3„ZdEd4d5„ZdFd6d7„ZdDd8d9„ZdEd:d;„ZdGdHdAdB„ZdS )Ié    )ÚannotationsN)ÚIOé   )ÚImage)úPIL._imagingZPILLOW_VERSION)zPIL._tkinter_finderZ
tk_version)úPIL._imagingftZfreetype2_version)zPIL._imagingcmsZlittlecms_version)z	PIL._webpZwebpdecoder_version)z	PIL._avifZlibavif_version)ÚpilÚtkinterÚ	freetype2Ú
littlecms2ÚwebpÚavifÚfeatureÚstrÚreturnÚboolc              
   C  s|   | t vrd| › �}t|ƒ‚t |  \}}zt|ƒ W dS  ty$   Y dS  ty= } zt t|ƒ¡ W Y d}~dS d}~w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Úwarnr   )r   ÚmsgÚmoduleÚverÚex© r   úRC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\PIL/features.pyÚcheck_module   s   
€þr   ú
str | Nonec                 C  s,   t | ƒsdS t|  \}}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$   ú	list[str]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>B   ó    z)get_supported_modules.<locals>.<listcomp>N)r   r   r   r   r   Úget_supported_modules>   ó   r-   )ZjpegZjpeglib)Zjpeg2kZjp2klib)ÚzipÚzlib)Úlibtiffr1   )ÚjpgÚjpg_2000r0   r1   c                 C  s:   | t vrd| › �}t|ƒ‚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 Ú_encoderN)Úcodecsr   Údirr   Úcore)r   r   ÚcodecÚlibr   r   r   Úcheck_codecM   s
   
r:   c                 C  sN   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Ú_versionr1   Ú
r   zVersion r   )r:   r5   r#   r   r7   Úsplit)r   r8   r9   Úversionr   r   r   Úversion_codec^   s   r?   c                   C  r&   )z3
    :returns: A list of all supported codecs.
    c                 S  r'   r   )r:   r(   r   r   r   r+   w   r,   z(get_supported_codecs.<locals>.<listcomp>N)r5   r   r   r   r   Úget_supported_codecss   r.   r@   )r   Z	HAVE_RAQMZraqm_version)r   ZHAVE_FRIBIDIZfribidi_version)r   ZHAVE_HARFBUZZZharfbuzz_version)r   ZHAVE_LIBJPEGTURBOÚlibjpeg_turbo_version)r   ZHAVE_MOZJPEGrA   )r   ZHAVE_ZLIBNGÚzlib_ng_version)r   ZHAVE_LIBIMAGEQUANTZimagequant_version)r   ZHAVE_XCBN)ÚraqmÚfribidiÚharfbuzzÚlibjpeg_turboÚmozjpegÚzlib_ngÚlibimagequantÚxcbz&dict[str, tuple[str, str, str | None]]Úfeaturesúbool | Nonec              
   C  sŠ   | t vrd| › �}t|ƒ‚t |  \}}}zt|dgd�}t||ƒW S  ty+   Y dS  tyD } zt t|ƒ¡ W Y d}~dS d}~w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)	rK   r   r   r#   r   r   r   r   r   )r   r   r   Úflagr   Zimported_moduler   r   r   r   Úcheck_feature†   s   
€þrO   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!   )rO   rK   r#   r   )r   r   rN   r   r   r   r   Úversion_featurež   s   rP   c                   C  r&   )z5
    :returns: A list of all supported features.
    c                 S  r'   r   )rO   r(   r   r   r   r+   ³   r,   z*get_supported_features.<locals>.<listcomp>N)rK   r   r   r   r   Úget_supported_features¯   r.   rQ   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'.é   )Ú
stacklevelFN)r   r   r5   r:   rK   rO   r   r   ©r   r   r   r   Úcheck¶   s   rU   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$   r5   r?   rK   rP   rT   r   r   r   r>   È   s   r>   c                  C  s"   t ƒ } |  tƒ ¡ |  tƒ ¡ | S )zJ
    :returns: A list of all supported modules, features, and codecs.
    N)r-   ÚextendrQ   r@   )Úretr   r   r   Úget_supportedØ   s   rX   TÚoutúIO[str] | NoneÚsupported_formatsÚNonec              	   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
pMd
› �| d� t jt jkrctdt j› �| d� tdt j› �| d� td| d� tdtj tj¡› �| d� tdtj tjj¡› �| d� td| d� dD ]›\}}t|ƒ�r+d}|dkr½tdƒ}|dur½tdƒrµdnd}|d| 7 }|du rÅt|ƒ}|du�r"|dv }|dkràtdd„ | d¡D ƒƒdk }|rädnd}	|dkrùtdƒ}
|
durø|d|
 7 }n|d k�rd!D ]}t|ƒ}|du�r|d"|› d|› �7 }�q td#|d$|	|| d� q˜td#|d%| d� q˜td&|d'| d� q˜td| d� |�rÖt t¡}tj ¡ D ]\}}||  |¡ �qGttjƒD ]~}|› }|tjv �rn|› dtj| › �}t|| d� ||v �r‰td(  d" !t|| ƒ¡¡| d� g }|tj"v �r–| d)¡ |tj#v �r¡| d*¡ |tj$v �r¬| d+¡ |tj%v �r·| d,¡ |tj&v �rÂ| d-¡ td.  d" !|¡¡| d� td| d� �qYdS dS )/a  
    Prints information about this installation of Pillow.
    This function can be called with ``python3 -m PIL``.
    It can also be called with ``python3 -m PIL.report`` or ``python3 -m PIL --report``
    to have "supported_formats" set to ``False``, omitting the list of all supported
    image file formats.

    :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 executable is Úunknownz%Environment Python files loaded from z System Python files loaded from z"Python Pillow modules loaded from z"Binary Pillow modules loaded from ))r   zPIL CORE)r	   ZTKINTER)r
   Z	FREETYPE2)r   Z
LITTLECMS2)r   ZWEBP)r   ZAVIF)r2   ZJPEG)r3   zOPENJPEG (JPEG2000))r0   zZLIB (PNG/ZIP))r1   ZLIBTIFF)rC   zRAQM (Bidirectional Text))rI   z#LIBIMAGEQUANT (Quantization method))rJ   zXCB (X protocol)r2   rF   rG   zlibjpeg-turboú )r   r2   r   c                 s  s   � | ]}t |ƒV  qd S )N)Úint)r)   Úxr   r   r   Ú	<genexpr>(  s   € zpilinfo.<locals>.<genexpr>Ú.)rR   é   zcompiled forZloadedr0   rH   z, compiled for zlib-ng rC   )rD   rE   z, z---zsupport ok,z
support okz***zsupport not installedzExtensions: {}ÚopenÚsaveZsave_allÚdecodeÚencodezFeatures: {})'ÚsysÚstdoutr   ÚinitÚprintrM   Ú__version__r>   Ú
splitlinesÚstripÚ
executableÚprefixÚbase_prefixÚosÚpathÚdirnameÚ__file__r7   rU   rP   rO   Útupler=   ÚcollectionsÚdefaultdictÚlistZ	EXTENSIONÚitemsÚappendÚsortedÚIDZMIMEÚformatÚjoinZOPENZSAVEZSAVE_ALLZDECODERSZENCODERS)rY   r[   Zpy_version_linesÚ
py_versionÚnamer   ÚvrA   Zversion_staticÚtrB   r*   Zv2Ú
extensionsÚextÚiÚlinerK   r   r   r   Úpilinfoã   s¤   
þþ

€

€

ÿ




ãr‰   )r   r   r   r   )r   r   r   r    )r   r%   )r   r   r   rL   )NT)rY   rZ   r[   r   r   r\   )Ú
__future__r   rx   rs   ri   r   Útypingr   rM   Ú r   r   r   r$   r-   r5   r:   r?   r@   rK   Ú__annotations__rO   rP   rQ   rU   r>   rX   r‰   r   r   r   r   Ú<module>   sT    ú



ü


ø





