K iDLddlmZddlZddlmZdZerddlmZGddZy)) annotationsN)BytesIOF)IOc@eZdZdZdZdd dZd dZed dZd dZ y) GimpPaletteFilez'File handler for GIMP's palette format.RGBc|jjds d}t|g}d} |r|dk(rn|dz }|j}|sntjd|r8|rt |dkDr d}t||j d t d kr d }t||fd td Dz }|rt |d k(rnt||_ y)Ns GIMP Paletteznot a GIMP palette fileris\w+:|#dzbad palette file)maxsplitzbad palette entryc3:K|]}t|ywN)int).0ivs Y/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/PIL/GimpPaletteFile.py z(GimpPaletteFile._read..;s4aAaD 4si) readline startswith SyntaxErrorrematchlensplit ValueErrorrangebytespalette)selffplimitmsgr rsrs @r_readzGimpPaletteFile._reads{{}''8+Cc" " g FA Axx A&Q#(!#&&#A1vz) o% 4584 4GW,/2W~ c&|j|yr)r&)r!r"s r__init__zGimpPaletteFile.__init__As  2r'c^|j|}|jt|d|S)NF)__new__r&r)clsdatar!s r frombyteszGimpPaletteFile.frombytesDs'{{3 74=%( r'c2|j|jfSr)r rawmode)r!s r getpalettezGimpPaletteFile.getpaletteJs||T\\))r'N)T)r" IO[bytes]r#boolreturnNone)r"r2r4r5)r-rr4r)r4ztuple[bytes, str]) __name__ __module__ __qualname____doc__r0r&r) classmethodr.r1r'rrrs.1G &D *r'r) __future__rrior TYPE_CHECKINGtypingrrr;r'rr@s% #  1*1*r'