
    .Ph                     T    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dS )	    Nc                     |g }t          | |                              |                                                                                                          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      b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/requests_toolbelt/utils/user_agent.py
user_agentr      sZ     ~'
 

.
 

 
  
 

.

5577#    c                   4    e Zd ZdZdZd Zd Zd Zd Zd Z	dS )	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          | _        dS )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                 P     d                      fd j        D                       S )zFinalize the User-Agent string.

        :returns:
            Formatted User-Agent string.
        :rtype:
            str
         c                 $    g | ]}j         |z  S  )format_string).0piecer   s     r   
<listcomp>z*UserAgentBuilder.build.<locals>.<listcomp>F   s!    NNN+e3NNNr   )joinr   r   s   `r   r   zUserAgentBuilder.build>   s.     xxNNNNNNNOOOr   c                     t          d |D                       rt          d          | j                            |           | S )zInclude extra portions of the User-Agent.

        :param list extras:
            list of tuples of extra-name and extra-version
        c              3   <   K   | ]}t          |          d k    V  dS )   N)len)r   extras     r   	<genexpr>z2UserAgentBuilder.include_extras.<locals>.<genexpr>N   s,      335s5zzQ333333r   z/Extras should be a sequence of two item tuples.)any
ValueErrorr   extend)r   r   s     r   r   zUserAgentBuilder.include_extrasH   sN     33F33333 	PNOOOF###r   c                 R    | 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_tupler    s    r   r   z'UserAgentBuilder.include_implementationT   s&     	133444r   c                 R    | 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   r      ss         $ M< < <P P P
 
 
      r   r   c                     t          j                    } | dk    rt          j                    }n| dk    rst          j        j        dt          j        j        dt          j        j        }t          j        j        dk    r&d	                    |t          j        j        g          }n6| dk    rt          j                    }n| dk    rt          j                    }n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55N""!)!8!:!:	6	!	!/2/D/J/J/J/2/D/J/J/J/2/D/J/J"L  -88%'WW&(=(J. & &" 
8	#	#!)!8!:!:	<	'	'!)!8!:!:!*233r   c                  $    dt                      z  S )Nr   )r,   r   r   r   _implementation_stringrH      s    *,,,,r   c                      	 t          j                    } t          j                    }n# t          $ r d} d}Y nw xY w| |fS )Nr;   )r<   systemreleaseIOError)p_system	p_releases     r   r.   r.      sZ    ?$$$&&		   			 i  s   &) ::)N)	r   r<   r?   r   objectr   r,   rH   r.   r   r   r   <module>rP      s         



# # # #0A A A A Av A A AH4 4 4B- - -! ! ! ! !r   