o
    üÞh  ã                   @  s>   d dl mZ d dlZd dlmZ d dlmZ G dd„ dƒZdS )é    )ÚannotationsN)ÚBytesIO)ÚIOc                   @  sB   e Zd ZdZdZddd
d„Zddd„Zeddd„ƒZddd„Z	dS )ÚGimpPaletteFilez'File handler for GIMP's palette format.ÚRGBTÚfpú	IO[bytes]ÚlimitÚboolÚreturnÚNonec                   sÒ   |  ¡  d¡sd}t|ƒ‚g }d}	 |r|dkrnI|d7 }|  ¡ }|s$n>t d|¡r+q|r9t|ƒdkr9d	}t|ƒ‚|jd
d�‰ tˆ ƒd
k rKd}t|ƒ‚|‡ fdd„td
ƒD ƒ7 }|rat|ƒdkranqt	|ƒ| _
d S )Ns   GIMP Paletteznot a GIMP palette filer   Ti  é   s   \w+:|#éd   zbad palette fileé   )Úmaxsplitzbad palette entryc                 3  s   � | ]	}t ˆ | ƒV  qd S ©N)Úint)Ú.0Úi©Úv© úS/var/www/html/premium_crap/venv/lib/python3.10/site-packages/PIL/GimpPaletteFile.pyÚ	<genexpr>8   s   € z(GimpPaletteFile._read.<locals>.<genexpr>i   )ÚreadlineÚ
startswithÚSyntaxErrorÚreÚmatchÚlenÚsplitÚ
ValueErrorÚrangeÚbytesÚpalette)Úselfr   r	   Úmsgr$   r   Úsr   r   r   Ú_read   s4   ézGimpPaletteFile._readc                 C  s   |   |¡ d S r   )r(   )r%   r   r   r   r   Ú__init__>   s   zGimpPaletteFile.__init__Údatar#   c                 C  s   |   | ¡}| t|ƒd¡ |S )NF)Ú__new__r(   r   )Úclsr*   r%   r   r   r   Ú	frombytesA   s   
zGimpPaletteFile.frombytesútuple[bytes, str]c                 C  s   | j | jfS r   )r$   Úrawmode)r%   r   r   r   Ú
getpaletteG   s   zGimpPaletteFile.getpaletteN)T)r   r   r	   r
   r   r   )r   r   r   r   )r*   r#   r   r   )r   r.   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__r/   r(   r)   Úclassmethodr-   r0   r   r   r   r   r      s    
"r   )Ú
__future__r   r   Úior   Útypingr   r   r   r   r   r   Ú<module>   s
   