a Æ*Na¬ã@sNddlZddlZddlZd dd„ZGdd„deƒZdd„Zdd „Zd d „ZdS) éNcCs(|dur 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 ú}/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/requests_toolbelt/utils/user_agent.pyÚ user_agents ÿýr c@s<eZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z d S)raï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/%scCst ||fg¡|_dS)zÕ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)Ú collectionsÚdequeÚ_pieces)Úselfrrr r r Ú__init__4szUserAgentBuilder.__init__csd ‡fdd„ˆjDƒ¡S)z„Finalize the User-Agent string. :returns: Formatted User-Agent string. :rtype: str ú csg|]}ˆj|‘qSr )Ú format_string)Ú.0Zpiece©rr r Ú Fóz*UserAgentBuilder.build..)Újoinrrr rr r>szUserAgentBuilder.buildcCs*tdd„|Dƒƒrtdƒ‚|j |¡|S)zŠInclude extra portions of the User-Agent. :param list extras: list of tuples of extra-name and extra-version css|]}t|ƒdkVqdS)éN)Úlen)rÚextrar r r Ú Nrz2UserAgentBuilder.include_extras..z/Extras should be a sequence of two item tuples.)ÚanyÚ ValueErrorrÚextend)rr r r r rHs zUserAgentBuilder.include_extrascCs|j tƒ¡|S)z¦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ÚappendÚ_implementation_tuplerr r r rTsz'UserAgentBuilder.include_implementationcCs|j tƒ¡|S)z2Append the information about the Operating System.)rr!Ú_platform_tuplerr r r r]szUserAgentBuilder.include_systemN) Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrrrr r r r rs    rcCsŒt ¡}|dkrt ¡}nj|dkr\dtjjtjjtjjf}tjjdkr„d  |tjjg¡}n(|dkrnt ¡}n|dkr€t ¡}nd}||fS) 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"cs$  þ ÿ  r"cCs dtƒS)Nr )r"r r r r Ú_implementation_string„sr:cCs8zt ¡}t ¡}Wnty.d}d}Yn0||fS)Nr.)r/ÚsystemÚreleaseÚIOError)Zp_systemZ p_releaser r r r#ˆs   r#)N) rr/r2r Úobjectrr"r:r#r r r r Ús D!