ó
o€
\c           @   se   d  d l  Z  d  d l Z d  d l Z d d „ Z d e f d „  ƒ  YZ d „  Z d „  Z d „  Z	 d S(   iÿÿÿÿNc         C   s=   | d k r g  } n  t |  | ƒ j | ƒ j ƒ  j ƒ  j ƒ  S(   s¿  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(   t   Nonet   UserAgentBuildert   include_extrast   include_implementationt   include_systemt   build(   t   namet   versiont   extras(    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyt
   user_agent   s
    	R   c           B   sA   e  Z d  Z d Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sï  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   %s/%sc         C   s   t  j | | f g ƒ |  _ d S(   sÕ   Initialize 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(   t   collectionst   dequet   _pieces(   t   selfR   R   (    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyt   __init__4   s    c         C   s*   d j  g  |  j D] } |  j | ^ q ƒ S(   s„   Finalize the User-Agent string.

        :returns:
            Formatted User-Agent string.
        :rtype:
            str
        t    (   t   joinR   t   format_string(   R   t   piece(    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyR   >   s    c         C   s9   t  d „  | Dƒ ƒ r% t d ƒ ‚ n  |  j j | ƒ |  S(   sŠ   Include 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(   i   N(   t   len(   t   .0t   extra(    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pys	   <genexpr>N   s    s/   Extras should be a sequence of two item tuples.(   t   anyt
   ValueErrorR   t   extend(   R   R   (    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyR   H   s    c         C   s   |  j  j t ƒ  ƒ |  S(   s¦   Append 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   t   appendt   _implementation_tuple(   R   (    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyR   T   s    c         C   s   |  j  j t ƒ  ƒ |  S(   s2   Append the information about the Operating System.(   R   R   t   _platform_tuple(   R   (    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyR   ]   s    (	   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   (    (    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyR      s   	
	
			c          C   sÑ   t  j ƒ  }  |  d k r' t  j ƒ  } n  |  d k r‹ d t j j t j j t j j f } t j j d k rÇ d j	 | t j j g ƒ } qÇ n< |  d k r¦ t  j ƒ  } n! |  d k rÁ t  j ƒ  } n d } |  | f S(	   sÎ  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.
    t   CPythont   PyPys   %s.%s.%st   finalt    t   Jythont
   IronPythont   Unknown(
   t   platformt   python_implementationt   python_versiont   syst   pypy_version_infot   majort   minort   microt   releaselevelR   (   t   implementationt   implementation_version(    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyR   c   s     	c           C   s   d t  ƒ  S(   Ns   %s/%s(   R   (    (    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyt   _implementation_string„   s    c          C   sF   y t  j ƒ  }  t  j ƒ  } Wn t k
 r; d }  d } n X|  | f S(   NR%   (   R&   t   systemt   releaset   IOError(   t   p_systemt	   p_release(    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyR   ˆ   s    
(
   R
   R&   R)   R    R	   t   objectR   R   R1   R   (    (    (    sW   /data/av2000/b2b/venv/lib/python2.7/site-packages/requests_toolbelt/utils/user_agent.pyt   <module>   s   D	!	