Ë
    T]jƒ  ã                   óÂ   — d dl Z d dlZd dlmZmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ d dlmZ e G d	„ d
e«      «       Ze G d„ de«      «       Z G d„ de
«      Zy)é    N)ÚBytesIOÚStringIO)ÚContentFile)ÚFileSystemStorage)ÚTestCase)Údeconstructible)Úimport_string)Úsettingsc                   ó*   ‡ — e Zd ZdZdˆ fd„	Zd„ Zˆ xZS )ÚTemporaryStoragez¬
    A storage class useful for tests that uses a temporary location to store
    all files and provides a method to remove this location when it is finished
    with.
    c                 ób   •— |€t        j                  «       }|| _        t        ‰| �  |d|i|¤Ž y)z0
        Create the temporary location.
        NÚlocation)ÚtempfileÚmkdtempÚtemporary_locationÚsuperÚ__init__)Úselfr   ÚargsÚkwargsÚ	__class__s       €úR/var/www/zogu/zoguvenv/lib/python3.12/site-packages/easy_thumbnails/tests/utils.pyr   zTemporaryStorage.__init__   s8   ø€ ð ÐÜ×'Ñ'Ó)ˆHØ&.ˆDÔ#Ü‰Ñ¨TÐ< (Ð<°VÓ<ó    c                 óN   — t        | dd«      }|rt        j                  |«       yy)z¨
        Delete the temporary directory created during initialisation.
        This storage class should not be used again after this method is
        called.
        r   N)ÚgetattrÚshutilÚrmtree)r   r   s     r   Údelete_temporary_storagez)TemporaryStorage.delete_temporary_storage   s)   € ô % TÐ+?ÀÓFÐÙÜ�M‰MÐ,Õ-ð r   )N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__©r   s   @r   r   r      s   ø„ ñõ=ö.r   r   c                   óN   ‡ — e Zd ZdZdZˆ fd„Zˆ fd„Zˆ fd„Zˆ fd„Zˆ fd„Z	ˆ xZ
S )ÚFakeRemoteStoragezc
    A temporary storage class that acts similar to remote storage.

    It's not thread safe.
    Fc                 óF   •— | j                   rt        ‚t        ‰| �  |i |¤ŽS )z†
        Raise ``NotImplementedError``, since this is the way that
        easy-thumbnails determines if a storage is remote.
        )Úremote_modeÚNotImplementedErrorr   Úpath©r   r   r   r   s      €r   r*   zFakeRemoteStorage.path3   s(   ø€ ð
 ×ÒÜ%Ð%Ü‰w‰|˜TÐ, VÑ,Ð,r   c                 óp   •— | j                   }d| _         	 t        ‰| �  |i |¤Ž|| _         S # || _         w xY w)NF)r(   r   Úexists)r   r   r   Úoriginal_remote_moder   s       €r   r-   zFakeRemoteStorage.exists<   s?   ø€ Ø#×/Ñ/ÐØ ˆÔð	4Ü‘7‘> 4Ð2¨6Ñ2à3ˆDÕøÐ3ˆDÕús   –, ¬	5c                 óX   •— d| _         	 t        ‰| �  |i |¤Žd| _         S # d| _         w xY w©NFT)r(   r   Úsaver+   s      €r   r1   zFakeRemoteStorage.saveD   ó2   ø€ Ø ˆÔð	$Ü‘7‘< Ð0¨Ñ0à#ˆDÕø˜tˆDÕúó   Š   	)c                 óX   •— d| _         	 t        ‰| �  |i |¤Žd| _         S # d| _         w xY wr0   )r(   r   Úopenr+   s      €r   r5   zFakeRemoteStorage.openK   r2   r3   c                 óX   •— d| _         	 t        ‰| �  |i |¤Žd| _         S # d| _         w xY wr0   )r(   r   Údeleter+   s      €r   r7   zFakeRemoteStorage.deleteR   s2   ø€ Ø ˆÔð	$Ü‘7‘> 4Ð2¨6Ñ2à#ˆDÕø˜tˆDÕúr3   )r   r    r!   r"   r(   r*   r-   r1   r5   r7   r#   r$   s   @r   r&   r&   *   s-   ø„ ñð
 €Kô-ô4ô$ô$÷$ð $r   r&   c                   ó8   ‡ — e Zd ZdZˆ fd„Zˆ fd„Z	 	 dd„Zˆ xZS )ÚBaseTestz¸
    Remove any customised THUMBNAIL_* settings in a project's ``settings``
    configuration module before running the tests to ensure there is a
    consistent test environment.
    c                 ó:   •— t         ‰| �  «       }dt        _        |S )z'
        Isolate all settings.
        T)r   ÚsetUpr
   Úisolated)r   Úoutputr   s     €r   r;   zBaseTest.setUpa   s   ø€ ô ‘‘“ˆØ ŒÔØˆr   c                 ó^   •— dt         _        t        j                  «        t        ‰| �  «       S )z;
        Restore settings to their original state.
        F)r
   r<   Úrevertr   ÚtearDown)r   r   s    €r   r@   zBaseTest.tearDowni   s%   ø€ ð "ŒÔÜ�‰ÔÜ‰wÑÓ!Ð!r   c                 óD  — |dk(  rddl m} t        «       }nddlm} t	        «       }|j                  ||«      5 }|j                  ||«       ddd«       |j                  d«       |s|S t        |j                  «       «      }	|j                  ||	«      }
|
S # 1 sw Y   ŒKxY w)zÀ
        Generate a test image, returning the filename that it was saved as.

        If ``storage`` is ``None``, the BytesIO containing the image data
        will be passed instead.
        ÚSVGr   )ÚImageN)
Úeasy_thumbnails.VILrC   r   ÚPILr   Únewr1   Úseekr   Úread)r   ÚstorageÚfilenameÚsizeÚ
image_modeÚimage_formatrC   ÚdataÚimgÚ
image_fileÚstorage_files              r   Úcreate_imagezBaseTest.create_imageq   sŒ   € ð ˜5Ò Ý1Ü“:‰Då!Ü“9ˆDØ�Y‰Y�z 4Ó(ð 	)¨CØ�H‰H�T˜<Ô(÷	)à�	‰	�!ŒÙØˆKÜ  §¡£Ó-ˆ
Ø—|‘| H¨jÓ9ˆØÐ÷	)ð 	)ús   ¹BÂB))i   iX  ÚRGBÚJPEG)r   r    r!   r"   r;   r@   rR   r#   r$   s   @r   r9   r9   Z   s   ø„ ñôô"ð 4>Ø4:÷r   r9   )r   r   Úior   r   Údjango.core.files.baser   Údjango.core.files.storager   Údjango.testr   Údjango.utils.deconstructr   Údjango.utils.module_loadingr	   Úeasy_thumbnails.confr
   r   r&   r9   © r   r   ú<module>r]      se   ðÛ Û ß  å .Ý 7Ý  Ý 4Ý 5å )ð ô.Ð(ó .ó ð.ð6 ô,$Ð(ó ,$ó ð,$ô^,ˆxõ ,r   