
     hi              
       n    d dl mZ d dlZd dlZdedee   dededef
dZg d	gd
dgdd
ggg dgg dgdZy)    )TupleN	icon_pathallowed_typesconvert_typeworkpathreturnc                    t         j                  j                  |       st        d|  d      t         j                  j	                  |       \  }}|dd }||v rUt
        |   }t        | d      5 }|j                  t        d |D                    ddd       t        fd|D              r| S 	 dd	l
m} ddl
}		 dt        j                  | j!                               j#                          d| }
t         j                  j%                  ||
      }|j                  |       5 }|j&                  dk(  r-|j(                  j+                  dd      |j-                  d      }|j/                  |       ddd       |} | S # 1 sw Y   xY w# t        $ r t        d
|  d| d| d| d	      w xY w# 1 sw Y   >xY w# |	j0                  $ r t        d|  d| d|       w xY w)a  
    Returns a valid icon path or raises an Exception on error.
    Ensures that the icon exists, and, if necessary, attempts to convert it to correct OS-specific format using Pillow.

    Takes:
    icon_path - the icon given by the user
    allowed_types - a tuple of icon formats that should be allowed through
        EX: ("ico", "exe")
    convert_type - the type to attempt conversion too if necessary
        EX: "icns"
    workpath - the temp directory to save any newly generated image files
    zIcon input file z
 not found   Nrbc              3   2   K   | ]  }t        |        y wN)len).0ss     EC:\des-py\Monitor\venv\Lib\site-packages\PyInstaller/building/icon.py	<genexpr>z&normalize_icon_type.<locals>.<genexpr>,   s     ;1A;s   c              3   R   K   | ]  }t              d t        |       |k(     y wr   )listr   )r   r   headers     r   r   z&normalize_icon_type.<locals>.<genexpr>-   s%     >atF|GSV$)>s   $'r   )ImagezReceived icon image 'zH' which exists but is not in the correct format. On this platform, only z images may be used as icons. If Pillow is installed, automatic conversion will be attempted. Please install Pillow or convert your 'z' file to one of z and try again.z
generated-.PtransparencyRGBAz,Something went wrong converting icon image 'z' to '.z' with Pillow, perhaps the image format is unsupported. Try again with a different file or use a file that can be used without conversion on this platform: )ospathexistsFileNotFoundErrorsplitexthex_signaturesopenreadmaxanyPILr   ImportError
ValueErrorhashlibsha256encode	hexdigestjoinmodeinfogetconvertsaveUnidentifiedImageError)r   r   r   r   _	extension
signaturesfPILImager%   _generated_namegenerated_iconimr   s                @r   normalize_icon_typer;      s     77>>)$"29+Z HII77##I.LAy!"I M!#I.
)T" 	=aVVC;
;;<F	=>:>>

)
&w~~i6F6F6H'I'S'S'U&VVWXdWefh@]]9% 	$ww#~"''++nd"C"O ZZ'GGN#	$ #	 K	= 	=  
#I; /!? #DDM;N_`m_n o
 	

	$ 	$ %% 
:9+W\N [<<I?L
 	

s>   0"E>1
F
 <A(F; $AF/2
F; >F
"F,/F84F; ;$G)   P   N   G      
      rA   M   Z   )r   r   r
   r   )i   c   n   s   )pngexeicoicns)typingr   r   r(   strr;   r         r   <module>rQ      sk     	 >3 >uSz >QT >`c >hk >H ==4L4,'$%%&	rP   