
    |h                     L    d dl Z d dlZd dlZddZ G d de      Zd Zd Zd Zy)	    Nc                     |g }t        | |      j                  |      j                         j                         j	                         S )a  Return an internet-friendly user_agent string.

    The majority of this code has been wilfully stolen from the equivalent
    function in Requests.

    :param name: The intended name of the user-agent, e.g. "python-requests".
    :param version: The version of the user-agent, e.g. "0.0.1".
    :param extras: List of two-item tuples that are added to the user-agent
        string.
    :returns: Formatted user-agent string
    :rtype: str
    )UserAgentBuilderinclude_extrasinclude_implementationinclude_systembuild)nameversionextrass      a/var/www/html/test/engine/venv/lib/python3.12/site-packages/requests_toolbelt/utils/user_agent.py
user_agentr      sF     ~'

.

 
  

.
557#    c                   2    e Zd ZdZdZd Zd Zd Zd Zd Z	y)	r   a  Class to provide a greater level of control than :func:`user_agent`.

    This is used by :func:`user_agent` to build its User-Agent string.

    .. code-block:: python

        user_agent_str = UserAgentBuilder(
                name='requests-toolbelt',
                version='17.4.0',
            ).include_implementation(
            ).include_system(
            ).include_extras([
                ('requests', '2.14.2'),
                ('urllib3', '1.21.2'),
            ]).build()

    %s/%sc                 >    t        j                  ||fg      | _        y)zInitialize our builder with the name and version of our user agent.

        :param str name:
            Name of our user-agent.
        :param str version:
            The version string for user-agent.
        N)collectionsdeque_pieces)selfr	   r
   s      r   __init__zUserAgentBuilder.__init__4   s     #((4/):;r   c                 x    dj                  | j                  D cg c]  }| j                  |z   c}      S c c}w )zFinalize the User-Agent string.

        :returns:
            Formatted User-Agent string.
        :rtype:
            str
         )joinr   format_string)r   pieces     r   r   zUserAgentBuilder.build>   s0     xxN++e3NOONs   7c                 v    t        d |D              rt        d      | j                  j                  |       | S )zInclude extra portions of the User-Agent.

        :param list extras:
            list of tuples of extra-name and extra-version
        c              3   8   K   | ]  }t        |      d k7    yw)   N)len).0extras     r   	<genexpr>z2UserAgentBuilder.include_extras.<locals>.<genexpr>N   s     35s5zQ3s   z/Extras should be a sequence of two item tuples.)any
ValueErrorr   extend)r   r   s     r   r   zUserAgentBuilder.include_extrasH   s5     3F33NOOF#r   c                 L    | j                   j                  t                      | S )zAppend the implementation string to the user-agent string.

        This adds the the information that you're using CPython 2.7.13 to the
        User-Agent.
        )r   append_implementation_tupler   s    r   r   z'UserAgentBuilder.include_implementationT   s     	134r   c                 L    | j                   j                  t                      | S )z2Append the information about the Operating System.)r   r'   _platform_tupler)   s    r   r   zUserAgentBuilder.include_system]   s    O-.r   N)
__name__
__module____qualname____doc__r   r   r   r   r   r    r   r   r   r      s(    $ M<P
r   r   c                  *   t        j                         } | dk(  rt        j                         }| |fS | dk(  rt        j                  j
                  dt        j                  j                  dt        j                  j                  }t        j                  j                  dk7  r+dj                  |t        j                  j                  g      }| |fS | dk(  rt        j                         }| |fS | dk(  rt        j                         }| |fS d}| |fS )	a  Return the tuple of interpreter name and version.

    Returns a string that provides both the name and the version of the Python
    implementation currently running. For example, on CPython 2.7.5 it will
    return "CPython/2.7.5".

    This function works best on CPython and PyPy: in particular, it probably
    doesn't work for Jython or IronPython. Future investigation should be done
    to work out the correct shape of the code for those platforms.
    CPythonPyPy.final Jython
IronPythonUnknown)
platformpython_implementationpython_versionsyspypy_version_infomajorminormicroreleaselevelr   )implementationimplementation_versions     r   r(   r(   c   s"    335N"!)!8!8!:  233 
6	!/2/D/D/J/J/2/D/D/J/J/2/D/D/J/J"L   --8%'WW&(=(=(J(J. &" 233 
8	#!)!8!8!: 233 
<	'!)!8!8!: 233 "+233r   c                      dt               z  S )Nr   )r(   r0   r   r   _implementation_stringrF      s    *,,,r   c                      	 t        j                         } t        j                         }| |fS # t        $ r
 d} d}Y | |fS w xY w)Nr9   )r:   systemreleaseIOError)p_system	p_releases     r   r+   r+      sT    ??$$$&	 i    	i  s   (. A A)N)	r   r:   r=   r   objectr   r(   rF   r+   r0   r   r   <module>rN      s2      
#0Av AH4B-!r   