
05Vc           @   s1   d  d l  Z  d  d l Z d d  Z d   Z d S(   iNc   
      C   s   y t  j   } t  j   } Wn t k
 r; d } d } n X| d k rQ g  } n  t d   | D  rv t d   n  d } g  | D] \ } } | | | f ^ q } | |  | f g | t   d | | f g }	 d j |	  S(   s  
    Returns 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
    t   Unknownc         s   s!   |  ] } t  |  d  k Vq d S(   i   N(   t   len(   t   .0t   extra(    (    sF   /usr/lib/python2.7/dist-packages/requests_toolbelt/utils/user_agent.pys	   <genexpr>   s    s/   Extras should be a sequence of two item tuples.s   %s/%st    N(	   t   platformt   systemt   releaset   IOErrort   Nonet   anyt
   ValueErrort   _implementation_stringt   join(
   t   namet   versiont   extrast   p_systemt	   p_releaset   format_stringt
   extra_namet   extra_versiont   extra_piecest   user_agent_pieces(    (    sF   /usr/lib/python2.7/dist-packages/requests_toolbelt/utils/user_agent.pyt
   user_agent   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 } d	 |  | f S(
   s  
    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
   IronPythonR    s   %s/%s(
   R   t   python_implementationt   python_versiont   syst   pypy_version_infot   majort   minort   microt   releaselevelR   (   t   implementationt   implementation_version(    (    sF   /usr/lib/python2.7/dist-packages/requests_toolbelt/utils/user_agent.pyR   /   s     
	(   R   R!   R	   R   R   (    (    (    sF   /usr/lib/python2.7/dist-packages/requests_toolbelt/utils/user_agent.pyt   <module>   s   )