o
    g*                  
   @  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lmZ ddd	d
ddZdBddZdCddZdDddZdddddZdBddZdCd d!ZdDd"d#Zd$d$d$d%d&d'd(d)d*d+	Zd,ed-< dEd/d0ZdCd1d2ZdDd3d4ZdEd5d6ZdCd7d8ZdDd9d:ZdFdGd@dAZdS )H    )annotationsN)IO   )Image)	deprecate)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webp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#   I/var/www/rescue_company/venv/lib/python3.10/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>)r   r#   r#   r#   r$   get_supported_modules>      r3   )jpegjpeglib)jpeg2kjp2klib)zipzlib)libtiffr;   )jpgjpg_2000r:   r;   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 _encoder)codecsr   dirr   core)r   r   codeclibr#   r#   r$   check_codecM   s
   
rD   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_versionr;   
r   zVersion r   )rD   r?   r)   r   rA   split)r   rB   rC   versionr#   r#   r$   version_codec^   s   rI   c                   C  r,   )z3
    :returns: A list of all supported codecs.
    c                 S  r-   r#   )rD   r.   r#   r#   r$   r1   w   r2   z(get_supported_codecs.<locals>.<listcomp>)r?   r#   r#   r#   r$   get_supported_codecss   r4   rJ   )r   TN)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xcbz-dict[str, tuple[str, str | bool, str | None]]featuresbool | Nonec              
   C  s   | t vrd|  }t|t |  \}}}t|tr"td|  dd zt|dgd}t|tr2|W S t||W S  tyA   Y dS  tyZ } 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 zcheck_feature("z")   PILr'   N)r_   r   
isinstancer   r   r   r)   r   r   r   r   r   )r   r   r    flagr!   imported_moduler"   r#   r#   r$   check_feature   s$   


rf   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'   )rf   r_   r)   r   )r   r    rd   r!   r#   r#   r$   version_feature   s   rg   c                  C  sp   g } t  D ]/\}\}}}|du r,t D ]\}\}}||kr*t|r(| |  nqqt|r5| | q| S )z5
    :returns: A list of all supported features.
    T)r_   itemsr   r%   appendrf   )supported_featuresr0   r    rd   _r   feature_moduler#   r#   r$   get_supported_features   s   

rm   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%   r?   rD   r_   rf   r   r   r   r#   r#   r$   check   s   rq   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*   r?   rI   r_   rg   rp   r#   r#   r$   rH      s   rH   c                  C  s"   t  } | t  | t  | S )zJ
    :returns: A list of all supported modules, features, and codecs.
    )r3   extendrm   rJ   )retr#   r#   r$   get_supported   s   rt   ToutIO[str] | Nonesupported_formatsNonec              	   C  st  | 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rtd}|durd| }|du rt|}|dur|dv }|dkrtdd |dD dk }|rdnd}	|dkrdD ]}
t|
}|dur|d|
 d| 7 }qtd|d |	|| d qtd|d!| d qtd"|d#| d qtd| d |rtt}tj D ]\}}|| | q'ttjD ]~}| }|tjv rN| dtj|  }t|| d ||v ritd$d t|| | d g }|tj!v rv|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 q9d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   TKINTER)r   	FREETYPE2)r   
LITTLECMS2)r   WEBP)r<   JPEG)r=   zOPENJPEG (JPEG2000))r:   zZLIB (PNG/ZIP))r;   LIBTIFF)rY   zRAQM (Bidirectional Text))r]   z#LIBIMAGEQUANT (Quantization method))r^   zXCB (X protocol)r<   r\   zlibjpeg-turbo )r   r<   r   c                 s  s    | ]}t |V  qd S )N)int)r/   xr#   r#   r$   	<genexpr>5  s    zpilinfo.<locals>.<genexpr>.)rn      zcompiled forloadedrY   )rZ   r[   z,  z---zsupport ok,z
support okz***zsupport not installedzExtensions: {}opensavesave_alldecodeencodezFeatures: {})&sysstdoutr   initprintrb   __version__rH   
splitlinesstrip
executableprefixbase_prefixospathdirname__file__rA   rq   rg   tuplerG   collectionsdefaultdictlist	EXTENSIONrh   ri   sortedIDMIMEformatjoinOPENSAVESAVE_ALLDECODERSENCODERS)ru   rw   py_version_lines
py_versionnamer   vrR   version_statictr0   v2
extensionsextiliner_   r#   r#   r$   pilinfo   s   









r   )r   r   r   r   )r   r   r   r&   )r   r+   )r   r   r   r`   )NT)ru   rv   rw   r   r   rx   )
__future__r   r   r   r   r   typingr   rb    r   
_deprecater   r   r%   r*   r3   r?   rD   rI   rJ   r_   __annotations__rf   rg   rm   rq   rH   rt   r   r#   r#   r#   r$   <module>   sV    
	










