capybara/virtualenv/lib/python2.7/site-packages/pip/download.py
def user_agent():
    """
    Return a string representing the user agent.
    """
    data = {
        "installer": {"name": "pip", "version": pip.__version__},
        "python": platform.python_version(),
        "implementation": {
            "name": platform.python_implementation(),
        },
    }

    if data["implementation"]["name"] == 'CPython':
        data["implementation"]["version"] = platform.python_version()
    elif data["implementation"]["name"] == 'PyPy':
        if sys.pypy_version_info.releaselevel == 'final':
            pypy_version_info = sys.pypy_version_info[:3]
        else:
            pypy_version_info = sys.pypy_version_info
        data["implementation"]["version"] = ".".join(
            [str(x) for x in pypy_version_info]
        )
    elif data["implementation"]["name"] == 'Jython':
        # Complete Guess
        data["implementation"]["version"] = platform.python_version()
    elif data["implementation"]["name"] == 'IronPython':
        # Complete Guess
        data["implementation"]["version"] = platform.python_version()

    if sys.platform.startswith("linux"):
        distro = dict(filter(
            lambda x: x[1],
            zip(["name", "version", "id"], platform.linux_distribution()),
        ))
        libc = dict(filter(
            lambda x: x[1],
            zip(["lib", "version"], platform.libc_ver()),
        ))
        if libc:
            distro["libc"] = libc
        if distro:
            data["distro"] = distro

    if sys.platform.startswith("darwin") and platform.mac_ver()[0]:
        data["distro"] = {"name": "OS X", "version": platform.mac_ver()[0]}

    if platform.system():
        data.setdefault("system", {})["name"] = platform.system()

    if platform.release():
        data.setdefault("system", {})["release"] = platform.release()

    if platform.machine():
        data["cpu"] = platform.machine()

    return "{data[installer][name]}/{data[installer][version]} {json}".format(
        data=data,
        json=json.dumps(data, separators=(",", ":"), sort_keys=True),
    )
def user_agent():
    """
    Return a string representing the user agent.
    """
    data = {
        "installer": {"name": "pip", "version": pip.__version__},
        "python": platform.python_version(),
        "implementation": {
            "name": platform.python_implementation(),
        },
    }

    if data["implementation"]["name"] == 'CPython':
        data["implementation"]["version"] = platform.python_version()
    elif data["implementation"]["name"] == 'PyPy':
        if sys.pypy_version_info.releaselevel == 'final':
            pypy_version_info = sys.pypy_version_info[:3]
        else:
            pypy_version_info = sys.pypy_version_info
        data["implementation"]["version"] = ".".join(
            [str(x) for x in pypy_version_info]
        )
    elif data["implementation"]["name"] == 'Jython':
        # Complete Guess
        data["implementation"]["version"] = platform.python_version()
    elif data["implementation"]["name"] == 'IronPython':
        # Complete Guess
        data["implementation"]["version"] = platform.python_version()

    if sys.platform.startswith("linux"):
        distro = dict(filter(
            lambda x: x[1],
            zip(["name", "version", "id"], platform.linux_distribution()),
        ))
        libc = dict(filter(
            lambda x: x[1],
            zip(["lib", "version"], platform.libc_ver()),
        ))
        if libc:
            distro["libc"] = libc
        if distro:
            data["distro"] = distro

    if sys.platform.startswith("darwin") and platform.mac_ver()[0]:
        data["distro"] = {"name": "OS X", "version": platform.mac_ver()[0]}

    if platform.system():
        data.setdefault("system", {})["name"] = platform.system()

    if platform.release():
        data.setdefault("system", {})["release"] = platform.release()

    if platform.machine():
        data["cpu"] = platform.machine()

    return "{data[installer][name]}/{data[installer][version]} {json}".format(
        data=data,
        json=json.dumps(data, separators=(",", ":"), sort_keys=True),
    )
def user_agent ( ) : data = { "installer" : { "name" : "pip" , "version" : pip . __version__ } , "python" : platform . python_version ( ) , "implementation" : { "name" : platform . python_implementation ( ) , } , } if data [ "implementation" ] [ "name" ] == 'CPython' : data [ "implementation" ] [ "version" ] = platform . python_version ( ) elif data [ "implementation" ] [ "name" ] == 'PyPy' : if sys . pypy_version_info . releaselevel == 'final' : pypy_version_info = sys . pypy_version_info [ : 3 ] else : pypy_version_info = sys . pypy_version_info data [ "implementation" ] [ "version" ] = "." . join ( [ str ( x ) for x in pypy_version_info ] ) elif data [ "implementation" ] [ "name" ] == 'Jython' : # Complete Guess data [ "implementation" ] [ "version" ] = platform . python_version ( ) elif data [ "implementation" ] [ "name" ] == 'IronPython' : # Complete Guess data [ "implementation" ] [ "version" ] = platform . python_version ( ) if sys . platform . startswith ( "linux" ) : distro = dict ( filter ( lambda x : x [ 1 ] , zip ( [ "name" , "version" , "id" ] , platform . linux_distribution ( ) ) , ) ) libc = dict ( filter ( lambda x : x [ 1 ] , zip ( [ "lib" , "version" ] , platform . libc_ver ( ) ) , ) ) if libc : distro [ "libc" ] = libc if distro : data [ "distro" ] = distro if sys . platform . startswith ( "darwin" ) and platform . mac_ver ( ) [ 0 ] : data [ "distro" ] = { "name" : "OS X" , "version" : platform . mac_ver ( ) [ 0 ] } if platform . system ( ) : data . setdefault ( "system" , { } ) [ "name" ] = platform . system ( ) if platform . release ( ) : data . setdefault ( "system" , { } ) [ "release" ] = platform . release ( ) if platform . machine ( ) : data [ "cpu" ] = platform . machine ( ) return "{data[installer][name]}/{data[installer][version]} {json}" . format ( data = data , json = json . dumps ( data , separators = ( "," , ":" ) , sort_keys = True ) , )
Return a string representing the user agent.
Return a string representing the user agent .