U
    Evfd  ã                   @  s2   d dl mZ d dlZddlmZ G dd„ dƒZdS )é    )ÚannotationsNé   ©Úo8c                   @  s$   e Zd ZdZdZdd„ Zdd„ ZdS )ÚGimpPaletteFilez'File handler for GIMP's palette format.ZRGBc                 C  sæ   dd„ t dƒD ƒ| _| ¡ d d… dkr4d}t|ƒ‚t dƒD ]–}| ¡ }|sP qÔt d|¡r^q<t|ƒdkrvd	}t|ƒ‚ttt	| 
¡ d d
… ƒƒ}t|ƒd
kr¨d}t|ƒ‚t|d ƒt|d ƒ t|d ƒ | j|< q<d | j¡| _d S )Nc                 S  s   g | ]}t |ƒd  ‘qS )é   r   )Ú.0Úi© r
   ú7/tmp/pip-unpacked-wheel-ciywl2yd/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ÚpaletteÚreadlineÚSyntaxErrorÚreÚmatchÚlenÚtupleÚmapÚintÚsplitÚ
ValueErrorr   Újoin)ÚselfÚfpÚmsgr	   ÚsÚvr
   r
   r   Ú__init__   s&    ,zGimpPaletteFile.__init__c                 C  s   | j | jfS )N)r   Úrawmode)r   r
   r
   r   Ú
getpalette8   s    zGimpPaletteFile.getpaletteN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r%   r$   r&   r
   r
   r
   r   r      s   r   )Ú
__future__r   r   Ú_binaryr   r   r
   r
   r
   r   Ú<module>   s   