
    L^i                     d    d dl Z d dlZd dlZd dlmZ d dlmZ  G d d          Z e            ZdS )    N)CacheAdapter)check_property_enabledc                       e Zd ZdZd Zd Zed             Zed             Z	e
d             Ze
d             Ze
d             Ze
d	             Zd
S )ResponsiveBreakpointsCachez6
    Caches breakpoint values for image resources
    c                 h    d| _         |                    d          }|                     |           dS )za
        Initialize the cache

        :param cache_options: Cache configuration options
        Ncache_adapter)_cache_adaptergetset_cache_adapter)selfcache_optionsr   s      PD:\Nbitz\venv\Lib\site-packages\cloudinary/cache/responsive_breakpoints_cache.py__init__z#ResponsiveBreakpointsCache.__init__   s9     #%))/::}-----    c                 F    |t          |t                    sdS || _        dS )z
        Assigns cache adapter

        :param cache_adapter: The cache adapter used to store and retrieve values

        :return: Returns True if the cache_adapter is valid
        NFT)
isinstancer   r	   )r   r   s     r   r   z,ResponsiveBreakpointsCache.set_cache_adapter   s+      
=,(O(O 5+tr   c                     | j         duS )zs
        Indicates whether cache is enabled or not

        :return: Rrue if a _cache_adapter has been set
        N)r	   r   s    r   enabledz"ResponsiveBreakpointsCache.enabled*   s     "$..r   c                      t          j        |           }t          j        j        di |\  }}|                     dd          }|                     dd          }|                     dd          }||||fS )z
        Extract the parameters required in order to calculate the key of the cache.

        :param options: Input options

        :return: A list of values used to calculate the cache key
        format typeuploadresource_typeimage )copydeepcopy
cloudinaryutilsgenerate_transformation_stringr
   )optionsoptions_copytransformation_file_formatstorage_typer   s          r   _options_to_parametersz1ResponsiveBreakpointsCache._options_to_parameters3   sy     }W--&,K[[l[[kk(B//{{6844OW==]NKGGr   c                 B     | j         di |} | j        j        |g|R  S )a'  
        Retrieve the breakpoints of a particular derived resource identified by the public_id and options

        :param public_id: The public ID of the resource
        :param options: The public ID of the resource

        :return: Array of responsive breakpoints, None if not found
        r   )r)   r	   r
   r   	public_idr#   paramss       r   r
   zResponsiveBreakpointsCache.getD   s:     -,77w77&t"&y:6::::r   c                     t          |t          t          f          st          d           | j        di |\  }}}}| j                            ||||||          S )a(  
        Set responsive breakpoints identified by public ID and options

        :param public_id: The public ID of the resource
        :param value:  Array of responsive breakpoints to set
        :param options: Additional options

        :return: True on success or False on failure
        z!A list of breakpoints is expectedr   )r   listtuple
ValueErrorr)   r	   set)r   r,   valuer#   r(   r   r%   r'   s           r   r2   zResponsiveBreakpointsCache.setR   so     54-00 	B@AAAC^4C^CiCiahCiCi@m^["&&y,~_jlqrrrr   c                 B     | j         di |} | j        j        |g|R  S )z
        Delete responsive breakpoints identified by public ID and options

        :param public_id: The public ID of the resource
        :param options: Additional options

        :return: True on success or False on failure
        r   )r)   r	   deleter+   s       r   r5   z!ResponsiveBreakpointsCache.deleted   s:     -,77w77)t"))=f====r   c                 4    | j                                         S )zd
        Flush all entries from cache

        :return: True on success or False on failure
        )r	   	flush_allr   s    r   r7   z$ResponsiveBreakpointsCache.flush_allr   s     ",,...r   N)__name__
__module____qualname____doc__r   r   propertyr   staticmethodr)   r   r
   r2   r5   r7   r   r   r   r   r   
   s         . . .   / / X/ H H \H  ; ; ; s s s" > > > / / / / /r   r   )	r   collectionsr    &cloudinary.cache.adapter.cache_adapterr   cloudinary.utilsr   r   instancer   r   r   <module>rB      s             ? ? ? ? ? ? 3 3 3 3 3 3o/ o/ o/ o/ o/ o/ o/ o/d &%''r   