

def parse_url(url):
    "\n    Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is\n    performed to parse incomplete urls. Fields not provided will be None.\n\n    Partly backwards-compatible with :mod:`urlparse`.\n\n    Example: ::\n\n        >>> parse_url('http://google.com/mail/')\n        Url(scheme='http', host='google.com', port=None, path='/', ...)\n        >>> parse_url('google.com:80')\n        Url(scheme=None, host='google.com', port=80, path=None, ...)\n        >>> parse_url('/foo?bar')\n        Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)\n    "
    scheme = None
    auth = None
    host = None
    port = None
    path = None
    fragment = None
    query = None
    if ('://' in url):
        (scheme, url) = url.split('://', 1)
    (url, path_, delim) = split_first(url, ['/', '?', '#'])
    if delim:
        path = (delim + path_)
    if ('@' in url):
        (auth, url) = url.rsplit('@', 1)
    if (url and (url[0] == '[')):
        (host, url) = url.split(']', 1)
        host += ']'
    if (':' in url):
        (_host, port) = url.split(':', 1)
        if (not host):
            host = _host
        if port:
            if (not port.isdigit()):
                raise LocationParseError(('Failed to parse: %s' % url))
            port = int(port)
        else:
            port = None
    elif ((not host) and url):
        host = url
    if (not path):
        return Url(scheme, auth, delim, port, path, query, fragment)
    if ('#' in path):
        (path, fragment) = path.split('#', 1)
    if ('?' in path):
        (path, query) = path.split('?', 1)
    return Url(scheme, auth, host, port, path, query, fragment)

dataset/ETHPy150Open Bolton-and-Menk-GIS/restapi/restapi/requests/packages/urllib3/util.py parse_url/VarMisuse@276/531 `host`->`delim`