o
    ‡®f“  ã                   @  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)ÚIOé   ©Úo8c                   @  s(   e Zd ZdZdZddd„Zdd
d„ZdS )ÚGimpPaletteFilez'File handler for GIMP's palette format.ÚRGBÚfpú	IO[bytes]ÚreturnÚNonec                 C  sà   dd„ t dƒD ƒ}| ¡ d d… dkrd}t|ƒ‚t dƒD ]J}| ¡ }|s' nAt d|¡r.qt|ƒdkr:d	}t|ƒ‚ttt| 	¡ d d
… ƒƒ}t|ƒd
krSd}t
|ƒ‚t|d ƒt|d ƒ t|d ƒ ||< qd |¡| _d S )Nc                 S  s   g | ]}t |ƒd  ‘qS )é   r   )Ú.0Úi© r   úL/home/ubuntu/webapp/venv/lib/python3.10/site-packages/PIL/GimpPaletteFile.pyÚ
<listcomp>   s    z,GimpPaletteFile.__init__.<locals>.<listcomp>é   é   s   GIMP Paletteznot a GIMP palette files   \w+:|#éd   zbad palette filer   zbad palette entryr   r   é   ó    )ÚrangeÚreadlineÚSyntaxErrorÚreÚmatchÚlenÚtupleÚmapÚintÚsplitÚ
ValueErrorr   ÚjoinÚpalette)Úselfr	   r$   Úmsgr   ÚsÚvr   r   r   Ú__init__   s&   *zGimpPaletteFile.__init__útuple[bytes, str]c                 C  s   | j | jfS )N)r$   Úrawmode)r%   r   r   r   Ú
getpalette9   s   zGimpPaletteFile.getpaletteN)r	   r
   r   r   )r   r*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r+   r)   r,   r   r   r   r   r      s
    
r   )Ú
__future__r   r   Útypingr   Ú_binaryr   r   r   r   r   r   Ú<module>   s
   