Viewing File: /usr/lib/python3.6/site-packages/pip/_vendor/urllib3/util/__pycache__/url.cpython-36.opt-1.pyc

3

aj@sddlmZddlmZddlZddlmZdddd	d
ddgZdZej	dZ
ddlmZGdddedeZ
ddZddZddZdS))absolute_import)
namedtupleN)LocationParseErrorschemeauthhostportpathqueryfragmenthttphttpsz[- ])quotecs^eZdZdZfZdfdd	ZeddZeddZed	d
Z	eddZ
d
dZZS)Urlz
    Datastructure for representing an HTTP URL. Used as a return value for
    :func:`parse_url`. Both the scheme and host are normalized as they are
    both case-insensitive according to RFC 3986.
    Nc	sV|r|jdrd|}|r$|j}|r8|tkr8|j}tt|j||||||||S)N/)
startswithlowerNORMALIZABLE_SCHEMESsuperr__new__)clsrrrr	r
rr)	__class__/usr/lib/python3.6/url.pyrszUrl.__new__cCs|jS)z@For backwards-compatibility with urlparse. We're nice like that.)r)selfrrrhostname$szUrl.hostnamecCs&|jpd}|jdk	r"|d|j7}|S)z)Absolute path including the query string.rN?)r
r)rZurirrrrequest_uri)s

zUrl.request_uricCs|jrd|j|jfS|jS)z(Network location including host and portz%s:%d)r	r)rrrrnetloc3sz
Url.netlocc	Cs|\}}}}}}}d}|dk	r*||d7}|dk	r>||d7}|dk	rN||7}|dk	rf|dt|7}|dk	rv||7}|dk	r|d|7}|dk	r|d|7}|S)a
        Convert self into a url

        This function should more or less round-trip with :func:`.parse_url`. The
        returned url may not be exactly the same as the url inputted to
        :func:`.parse_url`, but it should be equivalent by the RFC (e.g., urls
        with a blank port will have : removed).

        Example: ::

            >>> U = parse_url('http://google.com/mail/')
            >>> U.url
            'http://google.com/mail/'
            >>> Url('http', 'username:password', 'host.com', 80,
            ... '/path', 'query', 'fragment').url
            'http://username:password@host.com:80/path?query#fragment'
        Nz://@:r#)str)	rrrrr	r
rrurlrrrr%:s"zUrl.urlcCs|jS)N)r%)rrrr__str__bszUrl.__str__)NNNNNNN)
__name__
__module____qualname____doc__	__slots__rpropertyrrrr%r&
__classcell__rr)rrrs

(rcCszd}d}x8|D]0}|j|}|dkr&q|dks6||kr|}|}qW|dksR|dkr\|ddfS|d|||dd|fS)a
    Given a string and an iterable of delimiters, split on the first found
    delimiter. Return two split parts and the matched delimiter.

    If not found, then the first part is the full input string.

    Example::

        >>> split_first('foo/bar?baz', '?/=')
        ('foo', 'bar?baz', '/')
        >>> split_first('foo/bar?baz', '123')
        ('foo/bar?baz', '', None)

    Scales linearly with number of delims. Not ideal for large number of delims.
    Nrr )find)sZdelimsZmin_idxZ	min_delimdidxrrrsplit_firstfs


r3cCs|s
tStjdd|}d}d}d}d}d}d}d}d|krN|jdd\}}t|dddg\}}}	|	rp|	|}d	|kr|jd	d\}}|r|d
dkr|jdd\}}|d7}d
|kr|jd
d\}
}|s|
}|r|jst|yt|}Wnt	k
rt|YnXnd}n|r.|r.|}|sHt|||||||Sd|krb|jdd\}}d|kr||jdd\}}t|||||||S)a:
    Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is
    performed to parse incomplete urls. Fields not provided will be None.

    Partly backwards-compatible with :mod:`urlparse`.

    Example::

        >>> parse_url('http://google.com/mail/')
        Url(scheme='http', host='google.com', port=None, path='/mail/', ...)
        >>> parse_url('google.com:80')
        Url(scheme=None, host='google.com', port=80, path=None, ...)
        >>> parse_url('/foo?bar')
        Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)
    cSst|jS)N)rgroup)matchrrr<lambda>szparse_url.<locals>.<lambda>Nz://r.rrr#r!r[]r")
r!_contains_disallowed_url_pchar_resubsplitr3rsplitisdigitrint
ValueError)r%rrrr	r
rrZpath_ZdelimZ_hostrrr	parse_urlsR


r@cCst|}|jpd|j|jfS)z4
    Deprecated. Use :func:`parse_url` instead.
    r
)r@rrr	)r%prrrget_hostsrB)r
rN)Z
__future__rcollectionsrre
exceptionsrZ	url_attrsrcompiler9Zpackages.six.moves.urllib.parserrr3r@rBrrrr<module>s
U!a
Back to Directory File Manager