o
    èÅb_  ã                   @  s<   d dl mZ d dlmZmZ d dlmZ G dd„ deƒZdS )é    )Úannotations)Ú	UFOReaderÚ	UFOWriter)Ú	DataStorec                      sZ   e Zd ZdZeddd„ƒZeddd„ƒZeddd„ƒZeddd„ƒZd‡ fdd„Z	‡  Z
S )ÚImageSeta„  Represents a mapping of POSIX filename strings to arbitrary image data.

    Note:
        Images cannot be put into subdirectories of the images folder.

    Behavior:
        ImageSet behaves like a dictionary of type ``Dict[str, bytes]``.

        >>> from ufoLib2 import Font
        >>> font = Font()
        >>> # Note: invalid PNG data for demonstration. Use the actual PNG bytes.
        >>> font.images["test.png"] = b"123"
        >>> font.images["test2.png"] = b"456"
        >>> font.images["test.png"]
        b'123'
        >>> del font.images["test.png"]
        >>> list(font.images.items())
        [('test2.png', b'456')]
    Úreaderr   Úreturnú	list[str]c                 C  s   |   ¡ S )zAReturns a list of POSIX filename strings in the image data store.)ZgetImageDirectoryListing)r   © r
   ú:/usr/lib/python3/dist-packages/ufoLib2/objects/imageSet.pyÚlist_contents   s   zImageSet.list_contentsÚfilenameÚstrÚbytesc                 C  s
   |   |¡S )z4Returns the image data at filename within the store.)Z	readImage)r   r   r
   r
   r   Ú	read_data"   s   
zImageSet.read_dataÚwriterr   ÚdataÚNonec                 C  s   |   ||¡ dS )z3Writes the image data to filename within the store.N)Z
writeImage)r   r   r   r
   r
   r   Ú
write_data'   s   zImageSet.write_datac                 C  s   |   |¡ dS )z3Remove the image data at filename within the store.N)ZremoveImage)r   r   r
   r
   r   Úremove_data,   s   zImageSet.remove_dataÚfileNamec                   s"   d|v rt dƒ‚tƒ  ||¡ d S )Nú/z>Images cannot be put into subdirectories of the images folder.)Ú
ValueErrorÚsuperÚ__setitem__)Úselfr   r   ©Ú	__class__r
   r   r   1   s
   ÿzImageSet.__setitem__)r   r   r   r	   )r   r   r   r   r   r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   )r   r   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr   r   r   r   r   Ú__classcell__r
   r
   r   r   r      s    r   N)Z
__future__r   ZfontTools.ufoLibr   r   ZufoLib2.objects.miscr   r   r
   r
   r
   r   Ú<module>   s    