a
    Ag+                     @  sj  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dddddZdddddZddddZdddddZdddddZdddd d!Zddd"d#Zd$d$d$d%d&d'd(d)d*d+d,
Zd-ed.< dd/dd0d1Zdddd2d3Zddd4d5Zdd/dd6d7Zdddd8d9Zddd:d;ZdBd=dd>d?d@dAZdS )C    )annotationsN)IO   )Image)	deprecate)PIL._imagingZPILLOW_VERSION)zPIL._tkinter_finderZ
tk_version)PIL._imagingftZfreetype2_version)zPIL._imagingcmsZlittlecms_version)	PIL._webpZwebpdecoder_version)piltkinter	freetype2
littlecms2webpstrbool)featurereturnc              
   C  s   | t vrd|  }t|t |  \}}zt| W dS  tyH   Y dS  tyz } ztt| W Y d}~dS d}~0 0 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__ModuleNotFoundErrorImportErrorwarningswarnr   )r   msgmoduleverex r   K/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/PIL/features.pycheck_module   s    
r    z
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$   z	list[str])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>B       z)get_supported_modules.<locals>.<listcomp>)r   r   r   r   r   get_supported_modules>   s    r*   )ZjpegZjpeglib)Zjpeg2kZ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
    
r6   c                 C  sN   t | sdS t|  \}}ttj| d}| dkrJ|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   )r6   r1   r#   r   r3   split)r   r4   r5   versionr   r   r   version_codec^   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   )r6   r%   r   r   r   r(   w   r)   z(get_supported_codecs.<locals>.<listcomp>)r1   r   r   r   r   get_supported_codecss   s    r<   )r	   TN)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_ZLIBNGzlib_ng_version)r   ZHAVE_LIBIMAGEQUANTZimagequant_version)r   ZHAVE_XCBN)
Z	webp_animZwebp_muxZtransp_webpraqmfribidiharfbuzzlibjpeg_turbozlib_nglibimagequantxcbz-dict[str, tuple[str, str | bool, str | None]]featureszbool | Nonec              
   C  s   | t vrd|  }t|t |  \}}}t|trDtd|  dd z*t|dgd}t|trd|W S t||W S  ty   Y dS  ty } zt	
t| W Y d}~dS d}~0 0 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 zcheck_feature("z")   PILr!   N)rF   r   
isinstancer   r   r   r#   r   r   r   r   r   )r   r   r   flagr   Zimported_moduler   r   r   r   check_feature   s     


rK   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!   )rK   rF   r#   r   )r   r   rJ   r   r   r   r   version_feature   s    rL   c                  C  sp   g } t  D ]^\}\}}}|du rXt D ]*\}\}}||kr*t|rP| |  qjq*qt|r| | q| S )z5
    :returns: A list of all supported features.
    T)rF   itemsr   r    appendrK   )Zsupported_featuresr'   r   rJ   _r   Zfeature_moduler   r   r   get_supported_features   s    
rP   c                 C  sJ   | t v rt| S | tv r t| S | tv 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    r1   r6   rF   rK   r   r   r   r   r   r   check   s    rT   c                 C  s4   | t v rt| S | tv r t| S | tv 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$   r1   r;   rF   rL   rS   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*   extendrP   r<   )retr   r   r   get_supported   s    rW   TzIO[str] | NoneNone)outsupported_formatsr   c              	   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 qftd| d td	t j
pd
 | d t jt jkrt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 ]2\}}t|rRd}|dkrltd}|durld| }|du r~t|}|dur@|dv }|dkrtdd |dD dk }|rdnd}	|dkrtd}
|
dur*|d|
 7 }n<|dkr*dD ],}t|}|dur|d | d!| 7 }qtd"|d#|	|| d ntd"|d$| d ntd%|d&| d q0td| d |rtt}tj D ]\}}|| | qttjD ]}| }|tjv r| 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 rV|d* |tj$v rl|d+ |tj%v r|d, td-d  || d td| d qd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JPEG)r/   zOPENJPEG (JPEG2000))r,   zZLIB (PNG/ZIP))r-   ZLIBTIFF)r?   zRAQM (Bidirectional Text))rD   z#LIBIMAGEQUANT (Quantization method))rE   zXCB (X protocol)r.   rB   zlibjpeg-turbo )r
   r.   r   c                 s  s   | ]}t |V  qd S )N)int)r&   xr   r   r   	<genexpr>6  r)   zpilinfo.<locals>.<genexpr>.)rQ      zcompiled forZloadedr,   rC   z, compiled for zlib-ng r?   )r@   rA   z,  z---zsupport ok,z
support okz***zsupport not installedzExtensions: {}opensaveZsave_alldecodeencodezFeatures: {})&sysstdoutr   initprintrH   __version__r:   
splitlinesstrip
executableprefixbase_prefixospathdirname__file__r3   rT   rL   tupler9   collectionsdefaultdictlistZ	EXTENSIONrM   rN   sortedZIDZMIMEformatjoinZOPENZSAVEZSAVE_ALLZDECODERSZENCODERS)rY   rZ   Zpy_version_lines
py_versionnamer   vr=   Zversion_statictr>   r'   Zv2
extensionsextilinerF   r   r   r   pilinfo   s    

















r   )NT)
__future__r   rv   rq   rg   r   typingr   rH    r   Z
_deprecater   r   r    r$   r*   r1   r6   r;   r<   rF   __annotations__rK   rL   rP   rT   r:   rW   r   r   r   r   r   <module>   sV   	