o
    'j6h                     @  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 b/var/www/html/chefvision.cloud.itp360.com/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
   