o
    Vh                     @   sN   d dl Z d dlZd dlZdddZG dd deZdd Zdd	 Zd
d ZdS )    Nc                 C   s(   |du r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
    N)UserAgentBuilderinclude_extrasinclude_implementationinclude_systembuild)nameversionextras r
   v/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/requests_toolbelt/utils/user_agent.py
user_agent   s   r   c                   @   s<   e Zd ZdZdZdd Zdd Zdd Zd	d
 Zd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                 C   s   t ||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   r
   r
   r   __init__4   s   zUserAgentBuilder.__init__c                    s   d  fdd jD S )zFinalize the User-Agent string.

        :returns:
            Formatted User-Agent string.
        :rtype:
            str
         c                    s   g | ]} j | qS r
   )format_string).0piecer   r
   r   
<listcomp>F   s    z*UserAgentBuilder.build.<locals>.<listcomp>)joinr   r   r
   r   r   r   >   s   zUserAgentBuilder.buildc                 C   s*   t d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                 s   s    | ]	}t |d kV  qdS )   N)len)r   extrar
   r
   r   	<genexpr>N   s    z2UserAgentBuilder.include_extras.<locals>.<genexpr>z/Extras should be a sequence of two item tuples.)any
ValueErrorr   extend)r   r	   r
   r
   r   r   H   s   zUserAgentBuilder.include_extrasc                 C      | 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   r
   r
   r   r   T   s   z'UserAgentBuilder.include_implementationc                 C   r!   )z2Append the information about the Operating System.)r   r"   _platform_tupler   r
   r
   r   r   ]   s   zUserAgentBuilder.include_systemN)
__name__
__module____qualname____doc__r   r   r   r   r   r   r
   r
   r
   r   r      s    

	r   c                  C   s   t  } | dkrt  }| |fS | dkr4dtjjtjjtjjf }tjjdkr0d	|tjjg}| |fS | dkr@t  }| |fS | dkrLt  }| |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PyPyz%s.%s.%sfinal Jython
IronPythonUnknown)
platformpython_implementationpython_versionsyspypy_version_infomajorminormicroreleaselevelr   )implementationimplementation_versionr
   r
   r   r#   c   s,   
r#   c                   C   s
   dt   S )Nr   )r#   r
   r
   r
   r   _implementation_string   s   
r;   c                  C   s<   zt  } t  }W | |fS  ty   d} d}Y | |fS w )Nr/   )r0   systemreleaseIOError)p_system	p_releaser
   r
   r   r$      s   
r$   )N)	r   r0   r3   r   objectr   r#   r;   r$   r
   r
   r
   r   <module>   s   
D!