o
    &zhM  ã                   @   sD   d Z ddlZddlmZ ddlmZmZ dd„ Zdd	„ Zd
d„ Z	dS )z¨
Functions responsible for returning filenames for the given image generator.
Users are free to define their own functions; these are just some some sensible
choices.

é    N)Úsettingsé   )Úformat_to_extensionÚsuggest_extensionc                 C   sx   t | jddƒ}|du stj |¡rtj}ntj tjtj |¡d ¡}t	|p'd| j
ƒ}tj tj |d|  ¡ |f ¡¡S )a\  
    A namer that, given the following source file name::

        photos/thumbnails/bulldog.jpg

    will generate a name like this::

        /path/to/generated/images/photos/thumbnails/bulldog/5ff3233527c5ac3e4b596343b440ff67.jpg

    where "/path/to/generated/images/" is the value specified by the
    ``IMAGEKIT_CACHEFILE_DIR`` setting.

    ÚnameNr   Ú ú%s%s)ÚgetattrÚsourceÚosÚpathÚisabsr   ÚIMAGEKIT_CACHEFILE_DIRÚjoinÚsplitextr   ÚformatÚnormpathÚget_hash)Ú	generatorÚsource_filenameÚdirÚext© r   úU/var/www/html/kangema/venv/lib/python3.10/site-packages/imagekit/cachefiles/namers.pyÚsource_name_as_path   s   
ÿÿr   c              
   C   s–   t | jddƒ}|du stj |¡rtj}ntj tjtj |¡¡}t	|p%d| j
ƒ}tj |¡}tj tj |dtj |¡d |  ¡ dd… |f ¡¡S )aH  
    A namer that, given the following source file name::

        photos/thumbnails/bulldog.jpg

    will generate a name like this::

        /path/to/generated/images/photos/thumbnails/bulldog.5ff3233527c5.jpg

    where "/path/to/generated/images/" is the value specified by the
    ``IMAGEKIT_CACHEFILE_DIR`` setting.

    r   Nr   z%s.%s%sr   é   )r	   r
   r   r   r   r   r   r   Údirnamer   r   Úbasenamer   r   r   )r   r   r   r   r   r   r   r   Úsource_name_dot_hash-   s   

ÿ
ÿr   c                 C   s@   t | ddƒ}|rt|ƒnd}tj tj tjd|  ¡ |f ¡¡S )aB  
    A namer that, given the following source file name::

        photos/thumbnails/bulldog.jpg

    will generate a name like this::

        /path/to/generated/images/5ff3233527c5ac3e4b596343b440ff67.jpg

    where "/path/to/generated/images/" is the value specified by the
    ``IMAGEKIT_CACHEFILE_DIR`` setting.

    r   Nr   r   )	r	   r   r   r   r   r   r   r   r   )r   r   r   r   r   r   ÚhashL   s
   ÿr   )
Ú__doc__r   Údjango.confr   Úutilsr   r   r   r   r   r   r   r   r   Ú<module>   s    