Ë
    ±Œj7  ã                   óT   — d Z ddlmZmZ ddlmZmZ  G d„ de«      Z G d„ de«      Zy)	zŽ

requests_toolbelt.auth.handler
==============================

This holds all of the implementation details of the Authentication Handler.

é    )ÚAuthBaseÚHTTPBasicAuth)ÚurlparseÚ
urlunparsec                   óJ   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zed„ «       Z	d„ Z
d„ Zd	„ Zy
)ÚAuthHandlera¦  

    The ``AuthHandler`` object takes a dictionary of domains paired with
    authentication strategies and will use this to determine which credentials
    to use when making a request. For example, you could do the following:

    .. code-block:: python

        from requests import HTTPDigestAuth
        from requests_toolbelt.auth.handler import AuthHandler

        import requests

        auth = AuthHandler({
            'https://api.github.com': ('sigmavirus24', 'fakepassword'),
            'https://example.com': HTTPDigestAuth('username', 'password')
        })

        r = requests.get('https://api.github.com/user', auth=auth)
        # => <Response [200]>
        r = requests.get('https://example.com/some/path', auth=auth)
        # => <Response [200]>

        s = requests.Session()
        s.auth = auth
        r = s.get('https://api.github.com/user')
        # => <Response [200]>

    .. warning::

        :class:`requests.auth.HTTPDigestAuth` is not yet thread-safe. If you
        use :class:`AuthHandler` across multiple threads you should
        instantiate a new AuthHandler for each thread with a new
        HTTPDigestAuth instance for each thread.

    c                 óD   — t        |«      | _        | j                  «        y ©N)ÚdictÚ
strategiesÚ_make_uniform)Úselfr   s     úh/var/www/html/Fitness-lenito-AI-main/venv/lib/python3.12/site-packages/requests_toolbelt/auth/handler.pyÚ__init__zAuthHandler.__init__6   s   € Ü˜zÓ*ˆŒØ×ÑÕó    c                 óH   — | j                  |j                  «      } ||«      S r
   )Úget_strategy_forÚurl)r   ÚrequestÚauths      r   Ú__call__zAuthHandler.__call__:   s    € Ø×$Ñ$ W§[¡[Ó1ˆÙ�G‹}Ðr   c                 ó8   — dj                  | j                  «      S )Nz<AuthHandler({!r})>)Úformatr   ©r   s    r   Ú__repr__zAuthHandler.__repr__>   s   € Ø$×+Ñ+¨D¯O©OÓ<Ð<r   c                 ó�   — t        | j                  j                  «       «      }i | _        |D ]  \  }}| j                  ||«       Œ y r
   )Úlistr   ÚitemsÚadd_strategy)r   Úexisting_strategiesÚkÚvs       r   r   zAuthHandler._make_uniformA   s?   € Ü" 4§?¡?×#8Ñ#8Ó#:Ó;ÐØˆŒã)‰FˆQ�Ø×Ñ˜a Õ#ñ *r   c                 óš   — t        | «      }t        |j                  j                  «       |j                  j                  «       ddddf«      S )NÚ )r   r   ÚschemeÚlowerÚnetloc)r   Úparseds     r   Ú_key_from_urlzAuthHandler._key_from_urlH   sE   € ä˜#“ˆÜ˜6Ÿ=™=×.Ñ.Ó0Ø!Ÿ=™=×.Ñ.Ó0Ø˜r 2 rð+ó ,ð 	,r   c                 ót   — t        |t        «      rt        |Ž }| j                  |«      }|| j                  |<   y)a  Add a new domain and authentication strategy.

        :param str domain: The domain you wish to match against. For example:
            ``'https://api.github.com'``
        :param str strategy: The authentication strategy you wish to use for
            that domain. For example: ``('username', 'password')`` or
            ``requests.HTTPDigestAuth('username', 'password')``

        .. code-block:: python

            a = AuthHandler({})
            a.add_strategy('https://api.github.com', ('username', 'password'))

        N)Ú
isinstanceÚtupler   r)   r   )r   ÚdomainÚstrategyÚkeys       r   r   zAuthHandler.add_strategyO   s6   € ô  �h¤Ô&Ü$ hÐ/ˆHà× Ñ  Ó(ˆØ'ˆ�‰˜Òr   c                 ól   — | j                  |«      }| j                  j                  |t        «       «      S )a  Retrieve the authentication strategy for a specified URL.

        :param str url: The full URL you will be making a request against. For
            example, ``'https://api.github.com/user'``
        :returns: Callable that adds authentication to a request.

        .. code-block:: python

            import requests
            a = AuthHandler({'example.com', ('foo', 'bar')})
            strategy = a.get_strategy_for('http://example.com/example')
            assert isinstance(strategy, requests.auth.HTTPBasicAuth)

        )r)   r   ÚgetÚNullAuthStrategy)r   r   r/   s      r   r   zAuthHandler.get_strategy_fore   s/   € ð × Ñ  Ó%ˆØ�‰×"Ñ" 3Ô(8Ó(:Ó;Ð;r   c                 ó^   — | j                  |«      }|| j                  v r| j                  |= yy)ak  Remove the domain and strategy from the collection of strategies.

        :param str domain: The domain you wish remove. For example,
            ``'https://api.github.com'``.

        .. code-block:: python

            a = AuthHandler({'example.com', ('foo', 'bar')})
            a.remove_strategy('example.com')
            assert a.strategies == {}

        N)r)   r   )r   r-   r/   s      r   Úremove_strategyzAuthHandler.remove_strategyw   s1   € ð × Ñ  Ó(ˆØ�$—/‘/Ñ!Ø—‘ Ñ$ð "r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   Ústaticmethodr)   r   r   r4   © r   r   r   r      s?   „ ñ#òJòò=ò$ð ñ,ó ð,ò(ò,<ó$%r   r   c                   ó   — e Zd Zd„ Zd„ Zy)r2   c                  ó   — y)Nz<NullAuthStrategy>r:   r   s    r   r   zNullAuthStrategy.__repr__Š   s   € Ø#r   c                 ó   — |S r
   r:   )r   Úrs     r   r   zNullAuthStrategy.__call__�   s   € Øˆr   N)r5   r6   r7   r   r   r:   r   r   r2   r2   ‰   s   „ ò$ór   r2   N)	r8   Úrequests.authr   r   Úrequests.compatr   r   r   r2   r:   r   r   Ú<module>rA      s-   ðñ÷ 2ß 0ôw%�(ô w%ôt�xõ r   