Ë
    }D™jŽ  ã                   óþ   — d Z ddlmZ ddlmZ ddlmZmZ ddlZddl	m
Z
mZmZmZ ddlmZmZ  ee«      Zd	defd
edee
   dee   fd„Zd„ Zed„ «       Zed„ «       Zdee   fd„Zdefd„Zd„ Zd„ Zefdee   fd„Zy)a6  Utilities for patching ``requests``. See :ref:`patching` for general usage info.

.. warning::
    These functions are not thread-safe. Use :py:class:`.CachedSession` if you want to use caching
    in a multi-threaded environment.

.. automodsumm:: requests_cache.patcher
   :functions-only:
   :nosignatures:
é    )Úcontextmanager)Ú	getLogger)ÚOptionalÚTypeNé   )ÚBackendSpecifierÚ	BaseCacheÚinit_backendÚ	StrOrPath)ÚCachedSessionÚOriginalSessionÚ
http_cacheÚ
cache_nameÚbackendÚsession_factoryc                 óx   ‡‡— t        | ‰fi ‰¤ŽŠ‰j                  dd«        G ˆˆfd„d|«      }t        |«       y)a£  
    Install the cache for all ``requests`` functions by monkey-patching :py:class:`requests.Session`

    Example:

        >>> requests_cache.install_cache('demo_cache')

    Accepts all the same parameters as :py:class:`.CachedSession`. Additional parameters:

    Args:
        session_factory: Session class to use. It must inherit from either
            :py:class:`.CachedSession` or :py:class:`.CacheMixin`
    Ú	autocloseFc                   ó$   •‡ — e Zd Zˆ ˆˆfd„Zˆ xZS )ú/install_cache.<locals>._ConfiguredCachedSessionc                 ó(   •— t        ‰| �  dd‰i‰¤Ž y )Nr   © )ÚsuperÚ__init__)ÚselfÚ	__class__r   Úkwargss    €€€úb/var/www/html/Astrologybackend/backend/venv/lib/python3.12/site-packages/requests_cache/patcher.pyr   z8install_cache.<locals>._ConfiguredCachedSession.__init__2   s   ø€ Ü‰GÑÑ7 WÐ7°Ó7ó    )Ú__name__Ú
__module__Ú__qualname__r   Ú__classcell__)r   r   r   s   @€€r   Ú_ConfiguredCachedSessionr   1   s   ù„ ÷	8ò 	8r   r#   N)r
   Ú
setdefaultÚ_patch_session_factory)r   r   r   r   r#   s    ` ` r   Úinstall_cacher&      s?   ù€ ô& ˜: wÑ9°&Ñ9€Gð ×Ñ�k 5Ô)÷8 ?ô 8ô Ð3Õ4r   c                  ó"   — t        t        «       y)zHDisable the cache by restoring the original :py:class:`requests.Session`N)r%   r   r   r   r   Úuninstall_cacher(   8   s
   € äœ?Õ+r   c               #   ó€   K  — t         j                  } t        «        	 d–— t        | «       y# t        | «       w xY w­w)zÎ
    Context manager for temporarily disabling caching for all ``requests`` functions

    Example:

        >>> with requests_cache.disabled():
        ...     requests.get('https://httpbin.org/get')

    N)ÚrequestsÚSessionr(   r%   )Úpreviouss    r   Údisabledr-   =   s2   è ø€ ô ×Ñ€HÜÔð)Ûä˜xÕ(øÔ˜xÕ(üs   ‚>ž. ¢>®;»>c               /   ó^   K  — t        | i |¤Ž 	 d–— t        «        y# t        «        w xY w­w)a2  
    Context manager for temporarily enabling caching for all ``requests`` functions

    Example:

        >>> with requests_cache.enabled('cache.db'):
        ...     requests.get('https://httpbin.org/get')

    Accepts the same arguments as :py:class:`.CachedSession` and :py:func:`.install_cache`.
    N)r&   r(   )Úargsr   s     r   Úenabledr0   P   s)   è ø€ ô �4Ð"˜6Ò"ðÛäÕøŒÕüs   ‚-� “-ž*ª-Úreturnc                  ó@   — t        t        j                  «       dd«      S )zUGet the internal cache object from the currently installed ``CachedSession`` (if any)ÚcacheN)Úgetattrr*   r+   r   r   r   Ú	get_cacher5   c   s   € ä”8×#Ñ#Ó% w°Ó5Ð5r   c                  óF   — t        t        j                  «       t        «      S )z=Indicate whether or not requests-cache is currently installed)Ú
isinstancer*   r+   r   r   r   r   Úis_installedr8   h   s   € ä”h×&Ñ&Ó(¬-Ó8Ð8r   c                  óJ   — t        «       rt        «       j                  «        yy)z,Clear the currently installed cache (if any)N)r5   Úclearr   r   r   r:   r:   m   s   € ä„{Ü‹×ÑÕð r   c                  ó†   — t        j                  «       }t        |t        «      r |j                  j
                  | i |¤Ž yy)z~Remove responses from the cache according one or more conditions.
    See :py:meth:`.BaseCache.delete` for usage details.
    N)r*   r+   r7   r   r3   Údelete)r/   r   Úsessions      r   r<   r<   s   s:   € ô ×ÑÓ €GÜ�'œ=Ô)Øˆ�‰×Ñ˜dÐ- fÓ-ð *r   c                 óˆ   — t         j                  d| j                  › �«       | xt        _        t        j
                  _        y )Nz&Patching requests.Session with class: )ÚloggerÚdebugr   r*   r+   Úsessions)r   s    r   r%   r%   |   s3   € Ü
‡L�LÐ9¸/×:RÑ:RÐ9SÐTÔUØ3BÐB„HÔ”x×(Ñ(Õ0r   )Ú__doc__Ú
contextlibr   Úloggingr   Útypingr   r   r*   Úbackendsr   r	   r
   r   r=   r   r   r   r?   r&   r(   r-   r0   r5   Úboolr8   r:   r<   r%   r   r   r   ú<module>rH      sÏ   ðñ	õ &Ý ß !ã ç JÓ Jß 3á	�8Ó	€ð )Ø*.Ø-:ñ5Øð5àÐ&Ñ'ð5ð ˜/Ñ*ó5ò@,ð
 ñ)ó ð)ð$ ñó ðð$6�8˜IÑ&ó 6ð
9�dó 9ò
ò.ð ERñ C¨D°Ñ,Aô Cr   